相关疑难解决方法(0)

UIViewController init vs initWithNibName:bundle:

在我的应用程序中,我正在推动一个视图控制器(一个UITableViewController),它还有一个引用UITableViewCell的属性/出口.似乎用以下方法创建控制器:

PreferencesController *pController = [[PreferencesController alloc] init];
Run Code Online (Sandbox Code Playgroud)

不会在xib文件中为UITableViewCell创建对象,因此出口为空,因此表加载会生成异常.我解决了这个问题:

PreferencesController *pController = [[PreferencesController alloc] initWithNibName:@"PreferencesController" bundle:nil];
Run Code Online (Sandbox Code Playgroud)

但我真的不明白它为什么会起作用,因为从文档来看,init似乎足以加载相关的nib文件(PreferencesController.xib).

init uitableview uiviewcontroller ios

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

init ×1

ios ×1

uitableview ×1

uiviewcontroller ×1