我正在尝试理解我的应用程序的奇怪行为,以下是描述(在一个简单的项目中测试过)。
ViewControllerA以模态方式呈现ViewControllerB
ViewControllerB包含一个按钮,该按钮呈现了一个UIAlertController,具体如下:
alert = [UIAlertController alertControllerWithTitle:@"Test" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[alert addAction:[UIAlertAction actionWithTitle:@"Action" style:UIAlertActionStyleDefault handler:^(UIAlertAction *handler) { NSLog(@"Action"); }]];
ViewControllerB是以这种方式展示警报的
- (IBAction)button:(id)sender {
alert.popoverPresentationController.sourceView = self.button;
alert.popoverPresentationController.sourceRect = self.button.bounds;
[self presentViewController:alert animated:YES completion:nil];
}
现在,如果您单击按钮,会出现警报,如果您单击警报外部,警报将消失(我使用的是iPad)。您可以随意重复此操作...
以下是错误:当显示警报时,如果您在外部快速点击两次(大约0.2秒间隔),则警报会消失并且ViewControllerB也将被关闭。最后我们可以看到ViewControllerA,但我们从未要求过它。
还有一个警告消息:
Warning: Attempt to dismiss from view controller <UIViewController: 0x7f85ab633f70> while a presentation or dismiss is in progress!
谢谢您的帮助。
dismissViewControllerAnimated:completion
。 - Paul V