应用程序因此错误而崩溃
NSInvalidArgumentException :Pushing the same view controller instance more than once is not supported
尝试从另一个导航 Controller 的 UIBarButtonItem 推送另一个导航 Controller 时出现此错误。
控制台中显示消息:
UINavigationController pushViewController:transition:forceImmediate:]_block_invoke + 0
这是segue编码
else if ([segue.identifier isEqualToString:@"showGroupView"]) {
GroupView *groupView = (GroupView *)segue.destinationViewController;
[self.navigationController pushViewController:groupView animated:YES];
}
如果有人可以帮助解决此错误
最佳答案
错误消息准确地告诉您问题所在:您正在尝试推送已经在堆栈上的 View Controller 实例。
换句话说,segue.destinationViewController
已经被推送,因此它要么是当前 View Controller 的父级之一,要么是当前 Controller 本身。
如果不查看您的代码,就无法确定实际的原因。您可能遇到了与 this question 类似的问题,因为运行时允许事件发生两次。同样有可能与 segue 有关的某些内容已关闭。
作为第一步,我建议向 segue 添加日志语句(不是断点,因为它们会改变可观察的行为),以查看它是否被多次调用(因此与链接的问题类似) )。
关于ios - NSInvalidArgumentException :Pushing the same view controller instance more than once is not supported,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27993344/