简体   繁体   中英

attempt to dismiss modal view controller whose view does not currently appear

thanks for your time,here's my app's structure:It contains a MainController,and a LoginController, when user lanuch the app, first thing is to judge the login state,if it's yes, then set childController(aka.MainController) to RootViewController's (aka,NavigationController), else set childController(aka.LoginController) to RootViewController's (aka,NavigationController), when user input the username and password correctly,set childController(aka.MainController) to RootViewController's (aka,NavigationController)

When user click the quit button in the setting controller which belongs to MainController,then:

LoginController *vcLogin = [[LoginController alloc] init];
UINavigationController *ncRoot = [[UINavigationController alloc] initWithRootViewController:vcLogin];
[[UIApplication sharedApplication].keyWindow setRootViewController:ncRoot];

Now, the problem appears, console printed: attempt to dismiss modal view controller whose view does not currently appear.

 self = <_UIModalItemAppViewController: 0x9da0060> modalViewController =<_UIModalItemsPresentingViewController: 0x9e9bac0>

You know where the wrong-thing is?

This is not the way to set a new UIViewController. You should use presentViewController to present a modal view controller. If you want to use pushViewController without animation that's also possible. But it's a bad idea to change the rootViewController. Since that's not how the ViewController hierarchy is set up in iOS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM