在意外状态下完成导航过渡。导航栏子视图树可能已损坏

时间:2014-11-23 06:06:40

标签: ios navigationbar

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

 - (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];
 }  

那么出了什么问题?

2 个答案:

答案 0 :(得分:0)

1.注释导致此错误的执行segue

2.运行项目

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

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

我得到了这个,因为单按钮操作有多个segue活动。

答案 1 :(得分:0)

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