Push segues只能由UINavigationController Error使用

时间:2014-07-25 17:49:13

标签: ios objective-c uiviewcontroller storyboard

尝试执行"推送"时出现一个奇怪的错误UIViewController上的序列。

我已将两个UINavigationControllers嵌入到根UIViewController中。

我基本上试图在>按下按钮,它会推送到"视图控制器。"

为什么我收到以下错误的任何想法?:

*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.'

这是我的故事板:

http://cl.ly/image/3K0s3J1U1A3W

我像这样进入RecordViewController:

    RecordViewController *record = [self.storyboard instantiateViewControllerWithIdentifier:@"RecordView"];
    [self presentViewController:record animated:YES completion:nil];

1 个答案:

答案 0 :(得分:1)

如果要将视图控制器推送到显示的视图控制器,则显示的视图控制器必须是UINavigationController。在您的情况下,给最左边的导航控制器一个标识符(即RecordNavigationController)并将您的代码转换为:

UINavigationController *recordNavigationController = (UINavigationController*)[self.storyboard instantiateViewControllerWithIdentifier:@"RecordNavigationController"];
[self presentViewController:recordNavigationController animated:YES completion:nil];