我试图在另一个情节提要中设置视图控制器的属性(NSManagedObject)并显示它:
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MySecondStoryboard" bundle:nil];
MyViewController* initialView = [storyboard instantiateInitialViewController];
initialView.entity= self.entity;
initialView.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:initialView animated:YES completion:nil];
但是当它到达
initialView.entity= self.entity;
我懂了
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController setEntity:]: unrecognized selector sent to instance
有趣的是
MyViewController* initialView = [[MyViewController alloc] init];
initialView.entity= self.entity;
可以,但是我无法加载它,因为它应该由其情节提要实例化。
提前致谢
最佳答案
首先替换:
MyViewController* initialView = [storyboard instantiateInitialViewController];
与:
MyViewController* initialView = [storyboard instantiateViewControllerWithIdentifier:@"ID"];
最后转到第二个情节提要,然后转到视图控制器。将情节提要ID设置为“ID”。