我在 GameAppDelegate 中创建我的 managedObjectContext 并将其传递给我的第一个 ViewController (GameViewController),它没有嵌入 UINavigationController,然后我想将我的 managedObjectContext 传递给我嵌入在 navigationController 中的下一个视图。这是我迄今为止尝试做的prepareForSegue
:
UINavigationController *navController =(UINavigationController *)segue.destinationViewController;
((PickTypeViewController *)navController.viewControllers[0]).managedObjectContext=managedObjectContext;
但后来我收到以下错误:
Game[17878:c07] Uncaught exception: Could not find a navigation controller for segue 'Play'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.
为什么会这样