【发布时间】:2020-05-11 07:06:56
【问题描述】:
我无法在viewControllers 之间执行转换,因为navigationController 是nil。我在class 的不同部分记录了navigationController,但它到处都返回nil。在storyboard 中,viewController 嵌入在navigationController 中。我已经检查了SO 上的其他线程有同样的问题,但没有一个答案对我有帮助,甚至没有真正意义。
Can't push because self.navigationController is nil
navigationController is nil,when push the viewcontroller
为什么是零?我该如何解决这个问题?还会返回一条错误消息:
我都尝试过使用segue:
[self.navigationController performSegueWithIdentifier:@"experienceDetails" sender:self];
还有推:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Inspiration" bundle:nil];
ExperienceViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"experience"];
[self.navigationController pushViewController:viewController animated:NO];
使用push 没有任何反应,但会产生错误消息:
不允许在解除分配时尝试加载视图控制器的视图,这可能会导致未定义的行为
我也曾针对该错误寻找解决方案,但似乎没有明确具体的解决方法。同样,我阅读并尝试过的那些建议没有奏效。
我真的很茫然。这么简单的事情,但我什至不明白的事情阻碍了我。
编辑
如果有帮助,我有一个tab bar 和一个item 我有一个嵌入在navigationController 中的viewController,从那里我想push 到另一个viewController 在同一个storyboard .
编辑 我得到了这个工作:
[self showViewController:viewController sender:self];
很可能是因为它不使用navigationController。它虽然显示为modular,但不是导航堆栈的一部分,这不是我想要的。很高兴知道如果navigationController 不是 nil,一切都会奏效。
【问题讨论】:
标签: ios objective-c uiviewcontroller segue pushviewcontroller