Meaning of Warning "while a presentation is in progress!"

39,157

Solution 1

// Breaks
[viewController1 dismissViewControllerAnimated:YES completion:NULL];
[self presentViewController:viewController2 animated:YES completion:NULL];

// Does not break
[viewController1 dismissViewControllerAnimated:YES completion:^{
    [self presentViewController:viewController2 animated:YES completion:NULL];
}];

The Swift 3 version of the above code would look like this:

// Breaks
viewController1.dismiss(animated: true)
present(viewController2, animated: true)

// Does not break
viewController1.dismiss(animated: true) {
    present(viewController2, animated: true)
}

Note the use of the completion handler in the second example above.
It only presents viewController2 after viewController1 has been fully dismissed.

Solution 2

For those needing/wanting the swift 3 version, here it is

viewController1.dismiss(animated: true, completion: {
    self.present(self.viewController1, animated: true)
})

viewController1 is the viewcontroller you want to present.

Solution 3

It means you are presenting or dismissing UIImagePickerController and trying to present UIDocumentInteractionController, while first presentation or dismissing is not completed.

Solution 4

i got this message because i copied pasted a button that already had sent event attached to it and i continued to create another connection since new button was supposed to open new view.

So technically i was trying to open 2 views at the same time.

Solution 5

This means that you are presenting 2 ViewControllers at the same time. Call your delegate after the first presentation is completed.

Share:
39,157

Related videos on Youtube

chakshu
Author by

chakshu

Updated on March 01, 2020

Comments

  • chakshu
    chakshu about 4 years

    When I am integarting the Instagram in my project. I am getting a image from UIImagePickerController and after it i want to send it to Instagram But when I am sending image to Instagram by UIDocumentInteractionController delegate method presentOptionsMenuFromRect:inView: animated: like this

    [documentInteractionController presentOptionsMenuFromRect:CGRectZero inView:self.view animated:YES];
    

    The warning comes Warning: Attempt to present <_UIDocumentActivityViewController: 0x7584780> on while a presentation is in progress!
    The application is not Crashing. But I am not getting the Problem. Why this warning comes and what It means. I searched on Internet and read questions about this but not got any answer. Help me !!

    • Fattie
      Fattie over 10 years
      In short: you are opening the next view DURING THE CLOSING ANIMATION OF THE PREVIOUS ONE. This infuriating problem, is that simple. Simply uses John's code below to absolutely ensure the closing-animation has finished before the next one begins.
  • chakshu
    chakshu over 11 years
    can you tell me the proper solution of this problem.i can only call present UIDocumentInteractionController in the UIImagepicker's delegate method didFinishPickingImage
  • Timur Mustafaev
    Timur Mustafaev over 11 years
    Yes, you should present it in didFinishPickingImage method. After UIImagePicker will be dismissed
  • Ne AS
    Ne AS over 7 years
    Can you provide the Swift 3 version of this please?