NSInvalidArgumentException : 不支持多次推送同一个视图控制器实例 [英] NSInvalidArgumentException :Pushing the same view controller instance more than once is not supported

查看:24
本文介绍了NSInvalidArgumentException : 不支持多次推送同一个视图控制器实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用因此错误而崩溃

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

尝试从另一个导航控制器的 UIBarButtonItem 推送另一个导航控制器时出现此错误.

Getting this error when trying to push another navigationcontroller from another navigation controller's UIBarButtonItem.

控制台显示消息:

UINavigationController pushViewController:transition:forceImmediate:]_block_invoke + 0

这是转场编码

else if ([segue.identifier isEqualToString:@"showGroupView"]) {
        GroupView *groupView  = (GroupView *)segue.destinationViewController;

        [self.navigationController pushViewController:groupView animated:YES];
}

如果有人可以帮助解决此错误

If anyone can help resolve this error

推荐答案

好吧,这是我如何检查我的视图控制器是否在导航堆栈上但这实际上解决了我的问题

Well this i how i checked if my view controller is on the navigation stack or not but that actually solved my problem

if ([[self.navigationController topViewController] isKindOfClass:[groupView class]]){
          self.navigationController.navigationBarHidden = YES;
      }else{
          self.navigationController.navigationBarHidden = NO;
      }

所以整个代码都是这样的,供任何人参考

So the whole code goes like this for anyone reference though

else if ([segue.identifier isEqualToString:@"showGroupView"]) {
          GroupView *groupView  = (GroupView *)segue.destinationViewController;
      if ([[self.navigationController topViewController] isKindOfClass:[groupView class]]){
          self.navigationController.navigationBarHidden = YES;
      }else{
          self.navigationController.navigationBarHidden = NO;
      }
      NSLog(@"showGroupViewsegued");

  }

这篇关于NSInvalidArgumentException : 不支持多次推送同一个视图控制器实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆