我有两个 UIViewController,每个在 Storyboard中都有自己的 View 。在其中一个中,我有一个被调用的函数,我希望它更改为其他 ViewControllers View 。 我试过这个:
BRLoggedViewController *obj = [[BRLoggedViewController alloc] initWithNibName:@"BRLoggedViewController" bundle:nil];
[self.navigationController pushViewController:obj animated:NO];
我记录了第一个,它被调用了(我的意思是构造函数),但 View 没有改变。我忘记了什么? 感谢您的帮助
最佳答案
如果您使用的是 Storyboard,则必须从 Storyboard中获取 View ,如下所示:
BRLoggedViewController *obj = [self.storyboard instantiateViewControllerWithIdentifier:@"BRLoggedViewController"];
[self.navigationController pushViewController:obj animated:YES];
确保 ViewController 在 InterfaceBuilder 中为您的 Storyboard设置了正确的 Storyboard标识符。
关于iOS 7 : How to change to another UIViewController from an others method?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22105161/