tags:

views:

192

answers:

1

There are times when my application needs to present a modal view immediately after start-up. I have a method on my main view controller showEntryView that presents the modal view successfully in response to a button press. I also call showEntryView when my main view controller receives viewDidLoad, but in this case the view does not appear.

Intuition suggests that I am trying to present the modal view too early--that I should present it sometime after receiving viewDidLoad. But when?

+2  A: 

My intuition tells me that your modal view should probably be displaying itself in -viewDidAppear on your main view controller. However, without further code, that's all I've got.

-viewDidLoad probably happens long before -applicationDidFinishLaunching -- particularly if it's defined as the Main Nib file in your plist -- and the application probably isn't in a very sane state at that point. Allow your main view controller to appear, then present your modal...that means -viewDidAppear (or -viewWillAppear).

Jed Smith
viewDidLoad worked great! I did have to add a flag to track whether I'd handled the first viewDidAppear so that I wouldn't present the modal view continuously (the modal view would close and my main controller would receive viewDidAppear again). A small price to pay.
Curt Nichols