Whose view is not in the window hierarchy error resolution in IOS development

Source: Internet
Author: User

In IOS development, you often encounter the error of the whose view is not in the window hierarchy, which simply means that the "Viewcontroller" has not been caught, call the Viewcontroller or Vi This error is reported in the Ewcontroller method. Calling Viewcontroller in different places is not the same way to solve it. 1. This error occurs when calling another Viewcontroller inside a viewcontroller:This error is usually caused by a call inside the viewdidload, and the solution is transferred to the Viewdidappear method. 2. Call in APPDELEGATE.M encountered this errorSolution 1:uiviewcontroller *toprootviewcontroller = [UIApplication sharedapplication].keywindow.rootviewcontroller; while (toprootviewcontroller.presentedviewcontroller) {Toprootviewcontroller = Toprootviewcontroller.presentedviewcontroller; }//[toprootviewcontroller Presentviewcontroller:yourcontroller Animated:yes completion:nil];//or[ Toprootviewcontroller MyMethod];    Workaround 2:uistoryboard *mainstoryboard = [Uistoryboard storyboardwithname:@ "Mainstoryboard" bundle:nil]; loginviewcontroller* Loginviewcontroller = [Mainstoryboard instantiateviewcontrollerwithidentifier:@]    Loginviewcontroller "]; [Self.window Makekeyandvisible];//[loginviewcontroller Presentviewcontroller:yourcontroller Animated:YES  Completion:nil];//or[loginviewcontroller MyMethod]; Whose view is not in the window hierarchy error resolution in IOS development
Original address: http://www.cnblogs.com/xunziji/p/4025009.html

Whose view is not in the window hierarchy error resolution in IOS development

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.