時調用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