modalView が表示されると、ネットワーク イベントによって新しいモーダル ビュー コントローラーが生成されます。私がやっていることは、次のように presentViewController:animated を DismissViewControllerAnimated:completion 内にチェーンすることです。
// ModalViewController *vc = ...
if (self.presentedViewController) {
__weak MyViewController *me = self;
[self.presentedViewController dismissViewControllerAnimated:YES
completion:
^{
// need a delay to call?
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[me presentViewController:vc
animated:YES
completion:nil];
});
}];
}else{
[self presentViewController:vc animated:YES completion:nil];
}
元のモーダル ViewController が閉じられ、ネットワークによって生成されたものが表示され、ユーザーはそれを正常に閉じることができます。ただし、3 番目の modalViewController を表示しようとすると、次のエラーで失敗しました。
2014-03-26 15:49:52.111 coshop[6046:60b] Warning: Attempt to dismiss from view controller <RootViewController: 0xa8b54a0> while a presentation or dismiss is in progress!
私もこれを試しました:
if (self.presentedViewController) {
__weak MyViewController *me = self;
[self.presentedViewController dismissViewControllerAnimated:YES
completion:nil];
// dismiss animation ends within 0.5.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[me presentViewController:vc
animated:YES
completion:nil];
});
}else{
[self presentViewController:vc animated:YES completion:nil];
}
なにか提案を?ありがとう!