【问题标题】:Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted在意外状态下完成导航转换。导航栏子视图树可能会损坏
【发布时间】:2015-01-21 01:27:46
【问题描述】:

我在视图控制器中有两个不同的推送执行如下:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{  

     indexPathRow = indexPath.row;  

     NSLog(@"indexPathRow.%d", indexPathRow);  

    safetyInventoryList.recordIdToEdit = [DeviceIdArray objectAtIndex:indexPathRow] intValue];  

    NSLog(@"Item selected..%d", inventoryList.recordIdToEdit);  

    [self performSegueWithIdentifier:@"DetailsViewController" sender:nil];  

}  



 -(IBAction)ViewScoreBtn:(id)sender {  

     [self performSegueWithIdentifier:@"ScoreViewController" sender:nil];  

 }  

输入“viewscore”按钮 -> VC 后单击返回按钮时出现以下错误和黑屏。

nested push animation can result in corrupted navigation bar  
Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.  
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't add self as subview'  

更新的代码:在为 segue 做准备时,我有以下内容(在我展示的 VC 中):(.m)

 if([segue.identifier isEqualToString:@"ScoreViewController"]){  
        ScoreViewController *destViewController = segue.destinationViewController;  
        destViewController.delegate = self;  
    }  

 - (void)dismissScoreViewController:MVVMScoreViewController{  
    [self dismissViewControllerAnimated:YES completion: nil];  
 }  

在我提出的 VC(.h &.m) 中:

@protocol dismissScoreDelegate <NSObject>  

 - (void)dismissScoreViewController:SafetyDeviceViewController;  

@end  
 @property (nonatomic, assign) id<dismissScoreDelegate> delegate;  

 -(void) viewWillDisappear:(BOOL)animated {
    if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
        // Navigation button was pressed. Do some stuff
        [self.delegate dismissScoreViewController];
     }
   [super viewWillDisappear:animated];
 }  

所以出了什么问题?

【问题讨论】:

标签: ios navigationbar


【解决方案1】:

1.comment 导致这个错误的执行segue

2.运行项目

3.点击要执行导航的按钮/动作

4.检查重复或多次segue执行。

由于单个按钮操作的多个 segue 活动,我得到了这个。

【讨论】:

    【解决方案2】:

    使用 unwind segue 而不是 pop ,它会正常工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-07
      • 2011-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多