ios - NSInvalidArgumentException :Pushing the same view controller instance more than once is not supported

标签 ios uinavigationcontroller uistoryboardsegue

应用程序因此错误而崩溃

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/

相关文章:

iOS:从设备中选择音频文件并上传

ios - 什么时候应该重新计算 UITableView 页脚的大小?

ios - IBM Worklight/MobileFirst 6.x/7.0 - buildtime.sh 脚本出现 "Code object is not signed at all."错误

ios - Swift - 从 NavigationController 中的 UIViewController 到 TabBarController 中的 UIViewController

iphone - UINavigationController 偏移量

ios - 如何使用自定义转场将 AVPlayer 从源 VC 传递到目标 VC?

ios - performSegueWithIdentifier 在某些设备上不工作

ios - 是否可以在 Xcode 中为 SpriteKit 打开现场调试绘图?

ios - UINavigationController 背景颜色更改隐藏 iOS 中的后退按钮

objective-c - 使用 Xcode Storyboard 从 TableView 单元格推送到详细 View