PDA

View Full Version : Reloading A View




Lakario
Oct 30, 2008, 05:29 PM
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?



robbieduncan
Oct 30, 2008, 05:32 PM
viewDidLoad (https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/viewDidLoad) is only called when the view loads. viewDidAppear (https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/viewDidAppear:) is called when it appears.

Lakario
Oct 30, 2008, 06:30 PM
viewDidLoad (https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/viewDidLoad) is only called when the view loads. viewDidAppear (https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/viewDidAppear:) is called when it appears.

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.

robbieduncan
Oct 30, 2008, 06:36 PM
Erm, well the page I linked to lists all the methods defined in UIViewController. You may need to check sub/super classes too...

Lakario
Oct 30, 2008, 06:45 PM
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.

Lakario
Oct 30, 2008, 06:46 PM
Erm, well the page I linked to lists all the methods defined in UIViewController. You may need to check sub/super classes too...

Good call I didn't notice the links. :)

robbieduncan
Oct 30, 2008, 06:46 PM
viewDidAppear probably only gets called once the animation is complete. viewWillAppear may well get called before the animations starts...

Lakario
Oct 30, 2008, 06:56 PM
viewDidAppear probably only gets called once the animation is complete. viewWillAppear may well get called before the animations starts...

Yup figured that one out. Thanks for the help.