whose view is not in the window hierarchy
2016-07-10 22:43
405 查看
问题描述:有A、B两个view controller,在A的viewDidLoad方法中,调用presentViewController去present B View Controller,出现”whose view is not in the window hierarchy” warning,且没有正确跳转。
问题解释:
stack overflow 回答原文如下:
Where are you calling this method from? I had an issue where I was attempting to present a modal view controller within the
The solution for me was to move this call to the
My presumption is that the view controller's view is
not in the window's view hierarchy at the point that it has been loaded (when the
is sent), but it is in the window hierarchy after it has been presented (when the
is sent).
Caution
If you do make a call to
the
may run into an issue whereby the modal view controller is always being presented whenever the view controller's view appears (which makes sense!) and so the modal view controller being presented will never go away...
Maybe this isn't the best place to present the modal view controller, or perhaps some additional state needs to be kept
which allows the presenting view controller to decide whether or not it should present the modal view controller immediately.
stack overflow 链接:http://stackoverflow.com/questions/11862883/whose-view-is-not-in-the-window-hierarchy
解决方案:不要在A的viewDidLoad方法中,调用presentViewController来present B View Controller,而是在viewDidAppear中。理由是:viewDidLoad调用时,此时view controller’s view 并不在window 的view hierarchy中。
遗留问题:也许viewDidAppear中并不是最合适的转场地方。
问题解释:
stack overflow 回答原文如下:
Where are you calling this method from? I had an issue where I was attempting to present a modal view controller within the
viewDidLoadmethod.
The solution for me was to move this call to the
viewDidAppear:method.
My presumption is that the view controller's view is
not in the window's view hierarchy at the point that it has been loaded (when the
viewDidLoadmessage
is sent), but it is in the window hierarchy after it has been presented (when the
viewDidAppear:message
is sent).
Caution
If you do make a call to
presentViewController:animated:completion:in
the
viewDidAppear:you
may run into an issue whereby the modal view controller is always being presented whenever the view controller's view appears (which makes sense!) and so the modal view controller being presented will never go away...
Maybe this isn't the best place to present the modal view controller, or perhaps some additional state needs to be kept
which allows the presenting view controller to decide whether or not it should present the modal view controller immediately.
stack overflow 链接:http://stackoverflow.com/questions/11862883/whose-view-is-not-in-the-window-hierarchy
解决方案:不要在A的viewDidLoad方法中,调用presentViewController来present B View Controller,而是在viewDidAppear中。理由是:viewDidLoad调用时,此时view controller’s view 并不在window 的view hierarchy中。
遗留问题:也许viewDidAppear中并不是最合适的转场地方。
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 讲解iOS开发中基本的定位功能实现
- iOS中定位当前位置坐标及转换为火星坐标的方法
- js判断客户端是iOS还是Android等移动终端的方法
- iOS应用开发中AFNetworking库的常用HTTP操作方法小结
- iOS应用中UISearchDisplayController搜索效果的用法
- iOS App开发中的UISegmentedControl分段组件用法总结
- IOS开发环境windows化攻略
- iOS应用中UITableView左滑自定义选项及批量删除的实现
- iOS中UIAlertView警告框组件的使用教程
- 浅析iOS应用开发中线程间的通信与线程安全问题
- iOS中的UIKeyboard键盘视图使用方法小结
- 检测iOS设备是否越狱的方法
- .net平台推送ios消息的实现方法