添加自定义 UIViewController 与 UITableView 作为子视图 [英] Adding custom UIViewController with UITableView as a subview
问题描述
我正在尝试使用 UITableView 创建自定义 UIViewController,使用 xib 文件加载 UIViewController 并将视图作为子视图添加到另一个 UIView.
I'm trying to create custom UIViewController with a UITableView, load the UIViewController using a xib file and add the view as a subview to another UIView.
层次结构是这样的:
- UIViewController
- UIView
- 添加自定义 UIViewController 的视图
- 界面视图
- 界面视图
这是我的 xib 视图层次结构和设置:
Here's my xib view hierarchy and settings:
- 界面视图
- UITableView
IB 中的连接:
- 文件的所有者:CustomTableViewController
- 网点:
- 连接到 UIView 的视图
- 连接到文件所有者的表视图
- 委托连接到文件的所有者
- 连接到文件所有者的数据源
我同时实现了 UITableDataSource 和 UITableDelegate.当我尝试将视图添加为子视图时,它崩溃了......
I have both UITableDataSource and UITableDelegate implemented. When i tried to add the view as a subview, it crashed ...
- (void)viewDidLoad { [super viewDidLoad]; CustomTableViewController* controller = [[CustomTableViewController alloc] initWithNibName:@"CustomTableView" bundle:[NSBundle mainBundle]]; [self.viewContainer addSubview:controller.view]; }
我错过了什么?
推荐答案
听起来像是没有保留应该保留的东西.设置异常断点,开启僵尸查找.查看上面的提问者结果.
Sounds Like something is not retained that should be. Set up an exception breakpoint and turn on zombies to find it. See askers results above.
这篇关于添加自定义 UIViewController 与 UITableView 作为子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!