【发布时间】: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 新手,没有完全掌握。
-
我建议您阅读有关 View 控制器的 Apple 文档:developer.apple.com/library/ios/documentation/WindowsViews/…
标签: ios navigationbar