UIViewController.View.Window 在 ViewDidLoad 方法中为 null [英] UIViewController.View.Window is null in ViewDidLoad method

查看:18
本文介绍了UIViewController.View.Window 在 ViewDidLoad 方法中为 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论是哪种控制器类型(UIViewControllerUITableViewController),以下行总是在 ViewDidLoad 中产生 null> 方法:

Regardless on which controller type (UIViewController, UITableViewController), the following line always yields null in the ViewDidLoad method:

this.View.Window

这种行为是否正常,还是我在做一些奇怪的事情?什么会导致 UIViewController.View.Window 成为 null?

Is this behavior normal, or am I doing something odd? What could lead to UIViewController.View.Window being null?

(我想这个问题不仅涉及 MonoTouch,还涉及正常的"Objective-C Cocoa).

(I suppose this question concerns not only MonoTouch, but also 'normal' Objective-C Cocoa).

(MonoTouch 5.2.11, Xcode 4.2.1 4D502)

(MonoTouch 5.2.11, Xcode 4.2.1 4D502)

推荐答案

根据UIView,如果视图没有,window 属性为 nil尚未添加到窗口中,这是调用 viewDidLoad 时的情况.

According to the documentation of UIView, the window property is nil if the view has not yet been added to a window which is the case when viewDidLoad is called.

这篇关于UIViewController.View.Window 在 ViewDidLoad 方法中为 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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