我有一个UIViewController叫RootViewController和一个UIViewController叫NewsViewController。我想在我创建的内部显示NewsViewController(UIView这UIView只是屏幕的一部分)RootViewController。我正在使用 StoryBoard,我的应用程序需要支持 iOS 5(所以我不能使用来自 IB 的嵌入式 segues aka Containers)
RootViewController 代码:
- (void)viewDidLoad
{
    [super viewDidLoad];
    NewsViewController *news = [[NewsViewController alloc]init];
    news.view.frame = self.newsSection.bounds;
    [self.newsSection addSubview:news.view];
    [self addChildViewController:news];
    // Do any additional setup after loading the view.
}
我还将两个 UIViewControllers 都连接了一个 segue。UIView newsSection 将保持为空。我究竟做错了什么?
编辑:
这对我有用,这是正确的方法吗?
- (void)viewDidLoad
{
    [super viewDidLoad];
    UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    NewsViewController *news = [storyboard instantiateViewControllerWithIdentifier:@"NewsViewControllerID"];
    news.view.frame = self.newsSection.bounds;
    [self.newsSection addSubview:news.view];
    [self addChildViewController:news];
    [news didMoveToParentViewController:self];
}