0

我正在尝试使用它的故事板ID从故事板动态加载特定场景。它更像是通过故事板加载单独的 nib 文件。我有一个情节提要 ID 为“storyid”的场景。然后我尝试加载它,但加载时无法在我的屏幕上显示该场景。我在代码中没有错误。

- (IBAction)btnLoadSceneClicked:(id)sender
{
    NSLog(@"btnLoadSceneClicked");
    [self.storyboard instantiateViewControllerWithIdentifier:@"storyid"];
}
4

2 回答 2

2
YourViewControllerClass * viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"storyid"];
[self presentViewController: animated:YES completion:^{ /* what happens when the viewController is presented */}]

如果您嵌入在导航控制器中,您也可以推送 viewController。

[self.navigationController pushViewController:viewController animated:YES];
于 2013-10-09T06:22:20.180 回答
0
- (IBAction)btnLoadSceneClicked:(id)sender
{
    NSLog(@"btnLoadSceneClicked");
     YourViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"storyBoardID"];
    [viewController.view setFrame:CGRectMake(160, 0, self.view.frame.size.width, self.view.frame.size.height)];
    [self.view addSubview:viewController.view];
    [UIView animateWithDuration:0.50f animations:^{
        [viewController.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    } completion:^(BOOL finished) {
    }];
}
于 2013-10-09T06:40:25.680 回答