14
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

dismissViewControllerの後にpresentViewControllerでエラー

Posted at

dismissViewControllerの後にpresentViewControllerでエラー

下記のエラーメッセージが。

Warning: Attempt to present <ViewController: 0xc44c7e0> on <UITabBarController: 0xc482980> while a presentation is in progress

コードは下記のように、imagePickerControllerで画像が選択された際に、modalで表示している画面を閉じた後に、編集用のmodalを開くという動作。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    // 画像が選択されたら一旦画面を閉じる
    [_tabBarController dismissViewControllerAnimated:YES completion:nil];
    
    // 投稿画面を開く
    hogeViewController = [[hogeViewController alloc] initWithImage:[info objectForKey:UIImagePickerControllerOriginalImage]];
    [_tabBarController presentViewController:hogeViewController animated:YES completion:nil];
}

原因

  • dissmissのanimationがYESになっていたこと。
  • animationが実行中にpresentメソッドが実行されたために、処理がバッティングしてしまったみたい
14
12
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?