UIViewController *topRootViewController = [UIApplication sharedApplication].keyWindow.rootViewController; while (topRootViewController.presentedViewController) { topRootViewController = topRootViewController.presentedViewController; } //[topRootViewController presentViewController:yourController animated:YES completion:nil]; //or [topRootViewController myMethod];
解决办法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];
IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法
原文地址:http://www.cnblogs.com/xunziji/p/4025009.html
IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法
原文:http://www.cnblogs.com/csdnIOS/p/5017064.html