我正在尝试使用导航菜单从一个视图控制器转到另一个视图控制器。我的问题是它将从AddNewHomeTableViewController访问代码,但不会从故事板访问我的视图控制器。以下是我访问代码的方式:
AddNewHomeTableViewController *controller = [[AddNewHomeTableViewController alloc] init];
[weakSelf setViewControllers:@[controller] animated:YES];
拜托,谢谢!
答案 0 :(得分:1)
您不能使用alloc init访问故事板中的视图控制器(或在代码中创建)。您使用instantiateViewControllerWithIdentifier:。
AddNewHomeTableViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"AddHome"]; //be sure the identifier you use here is the same one you define in the storyboard