When viewDidLoad
is running, it may be that the frame
of the associated UIView has zero size. I don't know, but the UIAlertView
may be trying to present itself in this zero-size frame. Does it make sense if you present the UIAlertView
in viewDidAppear
?
If [self callMainMethod]
is taking lots of compute power, then the display might not be updated until it finishes. You could try moving it to viewDidAppear
. You could also try delaying it, so that the main run loop for the UI thread, the thread that the display is updated on and the thread that executesviewDidLoad
and all the other view...
methods, has time to complete everything and become idle before you start the heavy processing. It's only when the run loop has done all the processing it can that it starts actually to update the display. Like this:
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 200000000), dispatch_get_main_queue(), ^{
[self callMainMethod];
}
The documentation for that is at http://developer.apple.com/library/ios/#documentation/Performance/Reference/GCD_libdispatch_Ref/Reference/reference.html
If that suspicion is correct, you should then get the UIAlertView
popping straight up, only to have everything go dead for a while, while callMainMethod
executes.
I wish I knew how to write, "dispatch this block only after you've managed to finish updating the display with everything up to here", but I don't know how to do that. So the dispatch call above should delay the call to callMainMethod
by 200ms, which is usually plenty.
If that works, you should probably start another question, something like "How can I stop the display freezing while I execute this method."