时调用dismissViewControllerAnimated方法,我得到了与理解问题,iOS的视图控制器和报警控制器如何在特定的情况下工作:UINavigation收盘UIAlertController
我有一个自定义UINavigationController
,其中有我的UIViewController
。我的导航控制器已覆盖dismissViewControllerAnimated:completion
方法。从这个UIViewController
我提出了新的UIAlertController
。直到用户点击Alert中的任何按钮,一切正常。然而,奇怪的部分是,我的自定义的UINavigationController的dismissViewControllerAnimated:completion
方法被调用(我不希望出现这种情况,如果可能的话...)
警报呈现有规则地(从UINavigationController的内部的UIViewController):
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"yep" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self takeOrder:data];
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"nope" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[confirmOrderAcceptAlert addAction:okAction];
[confirmOrderAcceptAlert addAction:cancelAction];
[self presentViewController:alert animated:YES completion:nil];
是否有任何防止此行为的选项?为什么这首先发生?
编辑: 为dismissViewControllerAnimated:completion
代码:
- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
self.isHeroEnabled = NO;
[super dismissViewControllerAnimated:flag completion:completion];
}
我使用Hero库动画过渡,可能是这种情况?
请出示dismissViewControllerAnimated的代码:完成您的自定义navigationcontroller –
感谢您的答复,问题编辑 – Noiseapps