Question

This question already has an answer here:

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top