IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法
来源:互联网 发布:数据库运维主要做什么 编辑:程序博客网 时间:2024/05/21 03:28
在 IOS 开发当中经常碰到 whose view is not in the window hierarchy 的错误,该错误简单的说,是由于 "ViewController" 还没有被加载,就调用该 ViewController 或者 ViewController 内的方法时,就会报这个错误。
在不同地方调用 ViewController,解决的方法也不太一样。
1. 在 一个 ViewController 里面调用另外一个 ViewController 是出现这个错误:
该错误一般是由于在 viewDidLoad 里面调用引起的,解决办法是转移到 viewDidAppear 方法里面
2. 在 AppDelegate.m 中调用遇到这个错误
解决办法1:
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
原文地址:http://www.cnblogs.com/xunziji/p/4025009.html
0 0
- IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法
- IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法
- iOS 开发中 Whose view is not in the window hierarchy 错误的解决办法
- IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法
- [IOS开发记录]Whose view is not in the window hierarchy 错误的解决办法
- iOS Whose view is not in the window hierarchy 错误的解决办法
- 获取rootviewcontroller Whose view is not in the window hierarchy 错误的解决办法
- iOS开发出错whose view is not in the window hierarchy!的解决
- ios开发异常:whose view is not in the window hierarchy! (20
- iOS开发异常warning:***whose view is not in the window hierarchy!
- [ios开发异常]whose view is not in the window hierarchy!
- whose view is not in the window hierarchy!
- whose view is not in the window hierarchy!
- whose view is not in the window hierarchy
- whose view is not in the window hierarchy
- whose view is not in the window hierarchy
- whose view is not in the window hierarchy
- whose view is not in the window hierarchy!
- linux 性能监控命令top
- git基础介绍与GitKraken操作简记
- 支持VS2017的vax插件VA_X_Setup2210
- centOS6.5安装memcached
- JDBC知识概括(1)
- IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法
- VUE.JS——脚手架安装
- C语言中的volatile用法
- spring 父子容器
- JS中几种实用的跨域方法原理详解
- 抢金块(gold) 基础dp
- python Socket编程
- Elasticsearch自定义分词插件
- POJ1195/BZOJ1176 题解,CDQ分治