アプリの奇妙な動作を理解しようとしています。ここに説明があります(簡単なプロジェクトでテストされています)。
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 を使用しています)。何度でもできる...
バグは次のとおりです。アラートが表示されているときに、外側を 2 回クリックすると (すぐに ~0.2 秒間隔で)、アラートが消え、ViewControllerB が破棄されます。最後に ViewControllerA が表示されますが、それを求めたことはありません。
次の警告メッセージもあります。
Warning: Attempt to dismiss from view controller <UIViewController: 0x7f85ab633f70> while a presentation or dismiss is in progress!
ご協力ありがとうございました。