UINavigationController

UINavigationController

尝试在UIViewController上执行“推送”序列时收到奇怪的错误。

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

我基本上是试图做到这一点,所以当按下>按钮时,它将推送到“View Controller”。

为什么我会遇到以下错误?

*** 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];

最佳答案

如果要将视图控制器推送到已呈现的视图控制器,则所呈现的视图控制器必须为UINavigationController。在您的情况下,为最左侧的导航控制器提供一个标识符(即RecordNavigationController),然后将您的代码转换为:

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

10-08 05:42
查看更多