【发布时间】:2015-04-09 07:25:16
【问题描述】:
我有一个文本编辑视图,我想在文本编辑完毕后返回根视图之前提示用户。
到目前为止我已经尝试过了。
self.navigationItem.leftBarButtonItem.title = @"Back";
self.navigationItem.leftBarButtonItem.tintColor = [UIColor grayColor];
-(void) viewWillDisappear:(BOOL)animated {
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
// back button was pressed. We know this is true because self is no longer
// in the navigation stack.
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Confirm Submission" message:@"Current Job Sheet Incomplete\n Please Confirm Your Submission" delegate:self cancelButtonTitle:@"Submit" otherButtonTitles:@"Cancel", nil];
alert.tag = 1;
[alert show];
}
// [super viewWillDisappear:animated];
}
虽然这会显示警报,但它不会阻止用户被推送到根视图。
【问题讨论】:
标签: ios objective-c uinavigationcontroller uinavigationitem