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

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

问题描述

无论哪种控制器类型( UIViewController UITableViewController ),以下行总是产生 $ ViewDidLoad 方法中的

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 窗口如果视图尚未添加到窗口,则调用 viewDidLoad 时,属性为 nil

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.

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

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