其视图不在窗口层次结构中 [英] whose view is not in the window hierarchy

查看:127
本文介绍了其视图不在窗口层次结构中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚开始使用Xcode 4.5,我在控制台中遇到此错误:

Just started using Xcode 4.5 and I got this error in the console:


警告:尝试显示< finishViewController:0x1e56e0a0> on< ViewController:0x1ec3e000>其视图不在窗口层次中!

Warning: Attempt to present < finishViewController: 0x1e56e0a0 > on < ViewController: 0x1ec3e000> whose view is not in the window hierarchy!

视图仍在呈现, 。这是iOS 6中的新功能吗?

The view is still being presented and everything in the app is working fine. Is this something new in iOS 6?

这是我用来在视图之间切换的代码:

This is the code I'm using to change between views:

UIStoryboard *storyboard = self.storyboard;
finishViewController *finished = 
 [storyboard instantiateViewControllerWithIdentifier:@"finishViewController"];

[self presentViewController:finished animated:NO completion:NULL];


推荐答案

我有一个问题,我试图提出一个模式视图控制器在 viewDidLoad 方法。我的解决方案是将此调用移动到 viewDidAppear:方法。

Where are you calling this method from? I had an issue where I was attempting to present a modal view controller within the viewDidLoad method. The solution for me was to move this call to the viewDidAppear: method.

我假设视图控制器在窗口的视图层次结构中,在已加载的时候(当发送 viewDidLoad 消息时)查看 ),但是在它被呈现之后(当发送 viewDidAppear:消息时)

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 viewDidLoad message is sent), but it is in the window hierarchy after it has been presented (when the viewDidAppear: message is sent).

注意

如果你在 viewDidAppear:中调用 presentViewController:animated:completion:模式视图控制器总是在视图控制器的视图出现时被呈现(这是有意义的),因此呈现的模态视图控制器将永远不会消失...

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.

这篇关于其视图不在窗口层次结构中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆