IOS development error: attempt to dismiss modal view controller whose view does not currently appear

Source: Internet
Author: User

IOS development error: attempt to dismiss modal view controller whose view does not currently appear
I encountered a problem just now. Now I want to record it here. If you have any problems, you can quickly find the cause and share it with me. In the APP, you need to log on to the APP before using it. Therefore, I control the page Jump by changing [UIApplicationsharedApplication]. keyWindow. rootViewController of the APP. During use, the following problems occur: 1. Click the Logout button after logon is successful, and the logout prompt box UIAlertView is displayed; 2. Log On again after logon is successful; 3. Click logout again and the UIAlertView is not displayed. The following warning is displayed: Click the Logout button to change rootvie: attempt to dismiss modal view controller whose view does not currently appear when you click logout again: Attempt to present <_ UIModalItemsPresentingViewController: 0x7f9d1b5b2fd0> on <_ UIModalItemAppViewController: 0x7f9d1d335520> whose view isnot in the window hierarchy! My code is: LoginViewController * loginVC = [[LoginViewControlleralloc] init]; CNavigationController * nav = [[callback] initWithRootViewController: loginVC]; [UIApplicationsharedApplication]. keyWindow. rootViewController = nav; the main cause of this is: I am executing the above Code in:-(void) alertView :( UIAlertView *) alertView clickedButtonAtIndex :( NSInteger) buttonIndex; therefore, UIAlertView does not disappear when I switch the Root View Controller. Error: the disappearance of UIAlertView takes some time. Solution: To solve this problem, another proxy method-(void) alertView (UIAlertView *) in UIAlertView is used *) alertView didDismissWithButtonIndex :( NSInteger) in buttonIndex, perform the root controller switchover operation, that is, the above Code, that is, after the UIAlertView disappears completely, execute the root controller switchover to solve the problem!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.