I'm using xcode 5.1.1 with storyboard. I have a button on main menu and it pops to another view controller with this code
VC *secondVC = [[VC alloc] init];
[self presentViewController:secondVC animated:YES completion: nil];
And there I have back button with this code
[self dismissViewControllerAnimated:YES completion: nil];
And when I pop to secondVC xcode gives me is error:
Presenting view controllers on detached view controllers is discourage
<UINavigationController: 0x8c94510>
.
I'm also having problem with rotation, it doesn't work properly.
When it comes time to dismiss a presented view controller, the preferred approach is to let the presenting view controller dismiss it. In other words, whenever possible, the same view controller that presented the view controller should also take responsibility for dismissing it.
A view controller manages a single root view, which may itself contain any number of subviews. User interactions with that view hierarchy are handled by your view controller, which coordinates with other objects of your app as needed. Every app has at least one view controller whose content fills the main window.
This warning will come up if if you are trying to push, present or pop view controllers in viewWillAppear. I don't know what is in your code so it's tough to identify your problem but try using this if you are trying to show new views in viewWillAppear.
[self performSelector:@selector(yourMethod)
withObject:nil afterDelay:0.0];
Present the controller from viewDidAppear:
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With