Difference between viewDidAppear, viewDidLoad in iPhone/iOS? [duplicate]
Asked Answered
W

1

7

Bottom line is, I've been working on an app, and it seems that if I place a UIAlert in viewDidLoad, it gets called twice (from a delegate method of UIImagePickerController). If I put it in viewDidAppear, it gets called once.

I've looked through documentation but it just confuses me.

Wolfram answered 29/8, 2010 at 8:16 Comment(1)
have you tried setting a break point and checking the call stack?Quirt
M
9

A UIView object can get loaded into memory and released multiple times without ever getting added to the view stack and appearing on the display.

My guess is that you have 2 references to this view (maybe one in a nib file?), so it's getting loaded, then released when the second reference is loaded and assigned to the same property, then only the latter gets added to the view stack. You can see this by printing out (NSLog) the integer value of self ("%ld",(long int)self) in the viewDidLoad and viewDidAppear methods.

Metabolize answered 29/8, 2010 at 10:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.