0

モーダル ビュー コントローラーを表示しようとすると、例外が発生します。

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', 
reason: 'Attempting to begin a modal transition from <UINavigationController: 0x1d906060>
to <UINavigationController: 0x1da7a6d0> while a transition is already in progress. Wait
for viewDidAppear/viewDidDisappear to know the current transition has completed'

今、私は同様の質問を読みました.

[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(openModalController) userInfo:nil repeats:NO];

プレゼンテーションは次のようになります。

- (void)openImage:(ImageModel *)imageModel{
FullscreenImageViewController_iPhone * controller = [[FullscreenImageViewController_iPhone alloc] init];
controller.imageModel = imageModel;
UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController:controller];
UIViewController * visibleController = [[AppDelegate_iPhone app] visibleViewController];
[visibleController presentViewController:navController animated:YES completion:^{

}];
}

これは本当の解決策ではありませんよね?アプリのどこかでトランジションが行われているかどうかを確認し、現在のトランジションが終了した直後に新しいモーダル ビューを開くにはどうすればよいですか?

4

1 に答える 1

0

これは私にとってはうまくいきます。UIViewController の isBeingPresented および isBeingDismissed メソッドを使用して、プレゼンテーションまたは却下が進行中かどうかをテストする場合は、しばらく待ってから再試行してください。

- (void) presentVC {    
    if (presentingVC.isBeingPresented || presentingVC.isBeingDismissed) {
         double delayInSeconds = 0.3;
         dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
         dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
               [self presentVC];
         });
    }
    else {
        [presentingVC presentViewController:presentedVC animated:NO completion:nil];
    }
}
于 2013-11-27T14:22:03.470 に答える