ios - Error: Attempt to present <UIImagePickerController: on <ViewController: while a presentation is in progress


Question: 

Hey everyone and thank you for reading. I am making an app which you can take pictures and retreive pictures from the camera roll and display it on a view. The problem is that when I try to use the button which brings up the camera roll, I get the error "presentation is in progress" as above in the title.

if I comment out the code [self presentViewController:imagePicker animated:YES completion:NULL]; in the viewdidappear method I can bring up the camera roll... I have no idea how to properly dismiss this, I have tried [imagePicker dismissViewControllerAnimated:YES completion:NULL]; but to no avail.

here is my code! Thanks for checking it out.

-(IBAction)chooseExisting:(id)sender {

[imagePicker dismissViewControllerAnimated:YES completion:NULL];
imagePicker2 = [[UIImagePickerController  alloc] init];
imagePicker2.delegate = self;
[imagePicker2 setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:imagePicker2 animated:YES completion:NULL];

}

-(void)viewDidAppear:(BOOL)animated{
while (chooseExistingInt <1) {

overlayView.hidden = false;
imagePicker = [[UIImagePickerController  alloc] init];
imagePicker.delegate = self;
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:imagePicker animated:YES completion:NULL];
imagePicker.showsCameraControls = NO;
imagePicker.cameraOverlayView = overlayView;
    chooseExistingInt ++;
}
}

FIXED (maybe) I changed:

[imagePicker dismissViewControllerAnimated:YES completion:NULL];

to

[imagePicker dismissViewControllerAnimated:NO completion:NULL];

Changed the animated to "NO". WTF :s




2 Answers: 

Place your code which you want to perform in this

[[NSOperationQueue mainQueue] addOperationWithBlock:^{
//your code 
}];
 

It may help you . You are using the presentviewcontroller instead of the presentModalViewController

And in the dismissing also use the dismissModalViewController

 

More Articles


r - Control size of figure in Rstudio presentation

I'm creating a presentation in RStudio (.Rpres). I have a figure that is too large and extends beyond the screen. How can I reduce it?Too big, need to reduce sizeFigure 1========================================================![alt text](fig1)

Draw on second Screen using OnGestureDetection and Presentation API in Android?

Currently I have a setup which consists of a Smartphone and a pico-projector connected via MHL. I can send Images to the projector via the Presentation API with no problems. But now I came to the point, where I have to actively manipulate the second screen. I found hardly any information.Basically I

r - Line by line analysis and plotting on multiple monitors during presentation

I am preparing a presentation on data analysis and I am provided with a 2-3 monitor and projector head-up. I would like to use one monitor(+projector) for code, one monitor(+projector) for console display and one monitor(+projector) for plots. Monitors are for me, projectors for the audience. I woul


How to run a Video Presentation on Android in loop?

I have a group of Android Tablets and I need them to only run a Video Presentation as Company Gift Card.The idea of this project is the same of usually Company's Gift PENs, where the Company give to their presentation audience the information in the PEN, but this case we will have on an Android Tabl

r - select certain elements to build incrementally ioslides

I'm building a presentation using ioslides in RStudio. I have a following slide:```{r, echo=FALSE}logo<-"logo.jpg"```## Playing with R<IMG style="position:absolute;top:5.5%;right:5%;width:140px;"SRC="`r logo`">Type in the interactive console:```{r, eval=FALSE}x <- 1:10 # "name <- valu

git - replaying code for a hands on code presentation

So I need to conduct a workshop where I will be coding live on stage to build a demo app while the audience may follow.First problem is my typing speed is slow and secondly we have a fixed time span in which to complete the presentation.I have seen some youtube videos where presenters will use some


javascript - Make programmatically presentation

I would like to know if there is a way to create presentation (other than prezi's or powerpoint's) programmatically ?I mean maybe a library or something exists in a specific language (html/css or javascript would be great) ?Thanks for the answer :)

ipad - programmatically generate ppt in iOS

For generating PDF files we can use Core Graphics. Similarly is there any framework / class that can be used for generating .ppt (power point presentation) files via code ? Or is there any third party framework for this purpose.

vba - The specified value is out of range

I am trying to display slide no. in immediate window if they even one text box with a red font word. But the following error keeps popping up. Any ideas how I can go ahead.Run-time error'-2147024809(80070057)The specified value is out of range.Code:Sub redfont() Dim sld As Slide Dim shp As Sha

html - Vertical and Horizontal alignment

I am designing an html page where I need to display my inserted images. I want the arrangement of images in such a way :Image1 Image2 Image3 Image4 Image5 Image6 Image7 Image8 Image9<html> <head> <title>Display Images</title> </head> <body> {% for image in