Difference between viewDidAppear, viewDidLoad on iPhone / iOS?

On the bottom line, I was working on the application, and it seems that if I put the UIAlert in viewDidLoad , it will be called twice (from the delegate method of UIImagePickerController ). If I put it in viewDidAppear , it will be called once.

I looked through the documentation, but it just bothers me.

+6
ios iphone viewdidappear viewdidload
source share
1 answer

A UIView object can be loaded into memory and released several times without being added to the view stack and appearing on the display.

I assume that you have 2 links to this view (maybe one in the nib file?), So it becomes loaded and then freed when the second link is loaded and assigned to the same property, then only the last one is added to the view stack . You can see this by printing out the (NSLog) integer value self ("% ld", (long int) self) in the viewDidLoad and viewDidAppear methods.

+8
source share

All Articles