【发布时间】:2015-07-16 15:54:44
【问题描述】:
我正在尝试做这样的事情 -
- (void)viewDidLoad {
[super viewDidLoad];
ThingViewController *thingViewController = [self thingControllerForCard:self.card];
thingViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
UIView *view = [thingViewController view];
[self.view addSubview:view];
}
它只是给我一个白屏,里面什么都没有。如果我在导航堆栈上推送新的视图控制器,它会正确显示控制器。知道我可能缺少什么吗?
【问题讨论】:
-
你不应该只是将一个 VC 的视图添加到另一个视图控制器 - 你需要告诉两个 VC 他们有一个子/父视图控制器。相关方法调用在 Apple 的 View Controller Programming Guide 中的Implementing a Custom Container View Controller 中进行了描述。
标签: ios uiview uiviewcontroller uinavigationcontroller