Update view when activated

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

  1. blackend.dk macrumors newbie

    Joined:
    Jan 16, 2012
    #1
    Hi

    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 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    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

    dejo

    Staff Member

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

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #4


    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:



    Code:
    - (void)viewWillAppear:(BOOL)animated;
    

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

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


    Code:
    - (void)viewwillappear:(BOOL)animated;
    
     

Share This Page