iphone开发之viewDidLoad
在一篇名为
loadView 和 viewDidLoad 的区别
的copy文章中
写到 viewDidLoad 方法只有当 view 从 nib 文件初始化的时候才被调用。viewDidLoad 用于初始化,加载时用到。
不知道是谁先误解英文原文,写错了,却又许多人跟宝一样到处传
我想说的是
viewdidload和willappear是一个系列的东西,根本不是那么回事,没有这个限制,viewdidload是可以走到。
头文件这样写到
- (void)loadView; // This is where subclasses should create their custom view hierarchy if they aren't using a nib. Should never be called directly.- (void)viewDidLoad; // Called after the view has been loaded. For view controllers created in code, this is after -loadView. For view controllers unarchived from a nib, this is after the view is set.
就很明显了。
希望各位在学习iphone开发的朋友,多看看文档,自己多动手试试,不要被一些国内的文章所误导。
有某位网友回复说:
不过viewDidLoad 的确有时候不被调用.
在didFinishLaunchingWithOptions 中做个简单的例子
viewController.view = aNewView;
[self.window addSubview:viewController.view];
[self.window makeKeyAndVisible];
这个时候不被调用!!!
这个我没试过,也许是真的吧,试试才知道啊。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。