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