Ios 正在以意外状态完成导航转换。导航栏子视图树可能已损坏
我有两个不同的推送执行视图控制器,如下所示:Ios 正在以意外状态完成导航转换。导航栏子视图树可能已损坏,ios,navigationbar,Ios,Navigationbar,我有两个不同的推送执行视图控制器,如下所示: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ indexPathRow = indexPath.row; NSLog(@"indexPathRow.%d", indexPathRow); safetyInventoryList.recordIdToEdit = [D
- (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'
更新代码:在为赛格做准备时,我有以下内容(在我的演示VC中):(.m)
及
在我介绍的VC(.h和.m)中:
@protocol dismissscoregate
-(作废)dismissScoreViewController:SafetyDeviceViewController;
@结束
@属性(非原子,赋值)id委托;
-(无效)视图将消失:(BOOL)已设置动画{
if([self.navigationController.viewControllers indexOfObject:self]==NSNotFound){
//导航按钮被按下。做一些事情
[self.delegate dismissScoreViewController];
}
[超级视图将消失:动画];
}
那怎么了 1.注释导致此错误的执行顺序 2.管理项目 3.点击要执行导航的按钮/操作 4.检查重复或多段执行
我之所以这样做是因为单键操作的多段活动。使用“展开段”而不是“弹出段”,它会很好地工作。很抱歉,我是iOS新手,我没有完全理解它。我建议您阅读有关视图控制器的Apple文档:
if([segue.identifier isEqualToString:@"ScoreViewController"]){
ScoreViewController *destViewController = segue.destinationViewController;
destViewController.delegate = self;
}
- (void)dismissScoreViewController:MVVMScoreViewController{
[self dismissViewControllerAnimated:YES completion: nil];
}
@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];
}