Curt Nichols
Curt Nichols

Reputation: 2767

Need to present a modal view immediately on app start-up, but it doesn't appear

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?

Upvotes: 1

Views: 800

Answers (1)

Jed Smith
Jed Smith

Reputation: 15934

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).

Upvotes: 2

Related Questions