Reloading A View

Discussion in 'iPhone/iPad Programming' started by Lakario, Oct 30, 2008.

  1. macrumors member

    Joined:
    Oct 29, 2008
    #1
    I currently have a ItemViewController that receives an object and I use that object in the viewDidLoad() method in order to populate the fields on the view. This works fine the first time I go to the view but if the user backs out, selects another Item from the RootViewController and then goes back into the ItemViewController, the viewDidLoad() event is never fired again.

    Currently, I store the ItemViewController as a property within my RootViewController and reuse it in the cell click event. Should I instead create a new instance of the ItemViewController everytime they click a row, or is there a method I can use instead of viewDidLoad() that will be executed every time a view becomes the current screen?
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
  3. thread starter macrumors member

    Joined:
    Oct 29, 2008
    #3
    Great. I appreciate your help. Is there anywhere that lists the available overrides in their entirety? The sdk reference library is a freakin nightmare to navigate.
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Erm, well the page I linked to lists all the methods defined in UIViewController. You may need to check sub/super classes too...
     
  5. thread starter macrumors member

    Joined:
    Oct 29, 2008
    #5
    So I noticed that with viewDidAppear and the push set to animated that there is some visual lag between the view rendering and the fields being updated accordingly. If I disable animation then the problem is not present, but it detracts from the user experience somewhat. Is there any way to make sure the user doesn't see the values being updated as the view slides into place?

    Nevermind. I just found viewWillAppear(). Perfect.
     
  6. thread starter macrumors member

    Joined:
    Oct 29, 2008
    #6
    Good call I didn't notice the links. :)
     
  7. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #7
    viewDidAppear probably only gets called once the animation is complete. viewWillAppear may well get called before the animations starts...
     
  8. thread starter macrumors member

    Joined:
    Oct 29, 2008
    #8
    Yup figured that one out. Thanks for the help.
     

Share This Page