當(dāng)未從interface builder中為view屬性顯示指定outlet,或者此UIViewController是在程序中用代碼創(chuàng)建的,
當(dāng)訪問到view屬性,但是view屬性為nil值的時候,會調(diào)用到loadView方法創(chuàng)建view出來。
這就可以解釋
UIViewController *rootViewController = [[[UIViewController alloc] init] autorelease];
此時rootViewController.view為空
[self.window addSubview:rootViewController.view];
此時view已經(jīng)被創(chuàng)建了。
在UIViewController Class Reference有詳細(xì)說明
posted on 2011-06-01 15:23
小四 閱讀(1289)
評論(0) 編輯 收藏 引用