我正在尝试制作像iPad设置屏幕但在我的控制器上的子视图中...所以我不能使用UISplitViewController
我做了2个子视图的子视图,左边的一个是tablevew,右边是普通视图,用于子视图我要添加的控制器。
我正在使用此代码段
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ViewController * vc = [sb instantiateViewControllerWithIdentifier:@"vc"];
vc.view.frame = self.customView.bounds;
[self.customView addSubview:vc.view];
但它崩溃了
tableView:cellForRowAtIndexPath:]:发送给deallocated的消息
实例现在我启用了zombie obj
任何人都可以找出为什么会发生这种情况,甚至更好的是有一个开源组件可以做到这一点吗?
答案 0 :(得分:1)
对于contains a sub view controller。
的视图控制器,还需要做一些额外的工作UIStoryboard* sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ViewController * vc = [sb instantiateViewControllerWithIdentifier:@"vc"];
[self addChildViewController:vc]; // Before adding the subview
vc.view.frame = self.customView.bounds;
[self.customView addSubview:vc.view];
[vc didMoveToParentViewController:self]; // After adding the subview