如何修复警告:视图不在窗口层次结构中 [英] How to fix the warning: view is not in the window hierarchy

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

问题描述

我在 iOS 应用中使用 Mobclix 的标准设置程序,我正在调用 requestAndDisplayAdFromViewController: 中的方法viewWillAppear:

I'm using the standard setup procedure for Mobclix in an iOS app and I'm calling the requestAndDisplayAdFromViewController: method from within viewWillAppear:

    - (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    [fullScreenAdViewController requestAndDisplayAdFromViewController:self];

}

这是我收到的警告:

Warning: Attempt to present <MobclixFullScreenAdViewController: 0x14f2c0> on <EditGameViewController: 0x1838d0> whose view is not in the window hierarchy!

我希望这足以继续下去。感谢您的帮助。

I hope that's enough to go on. thanks for any help.

推荐答案

您从viewWillAppear调用它 - 此时,视图不一定在层次结构中(它会出现,并不意味着它已经出现)。尝试从viewDidAppear调用它,当视图被确认为在层次结构中时调用它。

You're calling it from viewWillAppear - at this point, the view is not necessarily in the hierarchy yet (it WILL appear, doesn't mean it has appeared yet). Try calling it from viewDidAppear, which is called when the view is confirmed to be in the hierarchy.

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

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