【发布时间】:2014-10-23 00:52:18
【问题描述】:
我正在制作一个 ipad 应用程序,它在情节提要中有 11 个视图控制器,其中一个是主视图,其中包含用于控制其他视图控制器中的哪个显示为其子视图的按钮。
有没有人知道是否可以使用 UIViewControllers 作为其他 UIViewControllers 的子视图,并有来自苹果或其他来源的确凿证据?到目前为止,使用这种方法对我来说效果很好:
int nextPage = (method to determine nextPage based on button pressed);
[currentView.view removeFromSuperview];
currentView = [self.storyboard instantiateViewControllerWithIdentifier:[NSString stringWithFormat:@"page%i",nextPage]];
[self.view insertSubview:currentView.view atIndex:0];
[currentView.view setFrame:CGRectMake(0, 0, 1024, 768)];
网上有人说如果你用的是ios5或更高版本就可以了,但也有人说“NO NEVER DO THIS!!!”即使是ios5。其他人说要使用容器视图,但在我见过的使用容器视图的每个教程中,您最终只是在插入子视图后将视图控制器作为子视图插入到主视图中:
[self.view addSubview:self.currentView];
我没有使用导航控制器,因为它们的可定制性有限,而且我不想要任何库存标签栏或导航栏,只需要所有自定义按钮。
提前致谢!
【问题讨论】:
标签: objective-c xcode ios7 uiviewcontroller uistoryboard