Just started using Xcode 4.5 and I got this error in the console:
Warning: Attempt to present < finishViewController: 0x1e56e0a0 > on < ViewCont
My issue was I was performing the segue in UIApplicationDelegate
's didFinishLaunchingWithOptions
method before I called makeKeyAndVisible()
on the window.
In case it helps anyone, my issue was extremely silly. Totally my fault of course. A notification was triggering a method that was calling the modal. But I wasn't removing the notification correctly, so at some point, I would have more than one notification, so the modal would get called multiple times. Of course, after you call the modal once, the viewcontroller that calls it it's not longer in the view hierarchy, that's why we see this issue. My situation caused a bunch of other issue too, as you would expect.
So to summarize, whatever you're doing make sure the modal is not being called more than once.
viewWillLayoutSubviews
and viewDidLayoutSubviews
(iOS 5.0+) can be used for this purpose. They are called earlier than viewDidAppear.
It's working fine try this.Link
UIViewController *top = [UIApplication sharedApplication].keyWindow.rootViewController;
[top presentViewController:secondView animated:YES completion: nil];
You can also get this warning when performing a segue from a view controller that is embedded in a container. The correct solution is to use segue from the parent of container, not from container's view controller.
Probably, like me, you have a wrong root viewController
I want to display a ViewController
in a non-UIViewController
context,
So I can't use such code:
[self presentViewController:]
So, I get a UIViewController:
[[[[UIApplication sharedApplication] delegate] window] rootViewController]
For some reason (logical bug), the rootViewController
is something other than expected (a normal UIViewController
). Then I correct the bug, replacing rootViewController
with a UINavigationController
, and the problem is gone.