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

Source: Internet
Author: User

Just encountered a problem, now in this as a record, we have encountered can quickly find the reason, share ah.

In the app, users need to log in before they can use it, so I change the app's [uiapplicationsharedapplication]. Keywindow. Rootviewcontroller to control the jump of the interface.

The following problems occur during use:

1. After successful login, click the logout button, eject the logout prompt box uialertview;

2. Log out successfully and login again;

3. Click Logout again to no longer eject Uialertview.

The following warning is indicated:

Click the Logout button to perform the change Rootvie operation:

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

Click Sign out again when you are prompted:

Attempt to present <_UIModalItemsPresentingViewController:0x7f9d1b5b2fd0> on <_ Uimodalitemappviewcontroller:0x7f9d1d335520> whose view isnot in the window hierarchy!

My Code is:

Loginviewcontroller *LOGINVC = [[loginviewcontrolleralloc] init];

cnavigationcontroller *nav = [[cnavigationcontrolleralloc] initwithrootviewcontroller: LOGINVC];

[uiapplicationsharedapplication]. Keywindow. Rootviewcontroller = nav;

The main causes of this are :

Because I execute the above code is in:-(void) Alertview: (uialertview *) Alertview clickedbuttonatindex: (nsinteger) Buttonindex This method is performed;

So when I do switch root view controller Uialertview is not gone, so there will be the above error, the disappearance of Uialertview will take a certain amount of time,

Solution:

To solve this problem is another proxy method in Uialertview -(void) Alertview: (Uialertview *) Alertview diddismisswithbuttonindex: (nsinteger) buttonindex in the operation of switching the root controller, that is, my code above, that is, after the Uialertview completely disappear after the switch root controller, solve!

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

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.