Update view when activated

Discussion in 'iOS Programming' started by blackend.dk, Jul 21, 2012.

  1. blackend.dk macrumors newbie

    Jan 16, 2012

    I have created a tab based application....

    On tab 2 I have my settings. This includes selecting a picture shown on page 1.
    When a new picture is selected on tab 2 I saved it in the nsdefaults.
    When I go back to tab 1 I need this viewcontroller to load the new picture and put it in a Imageview.

    How is this done the best. I cannot used Viewdidload or wievdidapper, as they are not "fired" going back to the view controller...

    I have also tried to change the image in the Imageview from tab2 without any luck...

    What do I do ?
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    viewWillAppear should be called.

    Otherwise you can post a NSNotification when the user chooses an image and any interested class can observe that notification.
  3. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    Accuracy is important in programming. Did you mean viewDidLoad and viewDidAppear?
  4. Duncan C macrumors 6502a

    Duncan C

    Jan 21, 2008
    Northern Virginia

    As demo says, you must get the method signature exactly right or the system won't call your method.

    The usual place to put cod to install data in a view controller's views is the viewWillAppear method. It's signature looks like this:

    - (void)viewWillAppear:(BOOL)animated;

    If you declare it like this (with no parameters) it won't get called:

    - (void)viewWillAppear;
    Or if you get the capitalization wrong:

    - (void)viewwillappear:(BOOL)animated;

Share This Page