2

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

Undo
  • 25,519
  • 37
  • 106
  • 129
Barney Chambers
  • 2,720
  • 6
  • 42
  • 78

2 Answers2

4

Place your code which you want to perform in this

[[NSOperationQueue mainQueue] addOperationWithBlock:^{
//your code 
}];
Akshay Sunderwani
  • 12,428
  • 8
  • 29
  • 52
0

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

And in the dismissing also use the dismissModalViewController

user247
  • 416
  • 3
  • 14
  • Thanks for your suggestion, I shall try that. I am getting a warning, saying that "this method is deprecated." is this a problem? Edit: I tried this, and I got the same error :/ – Barney Chambers Jan 31 '13 at 10:03
  • Deprecation doesn't create any issues – user247 Jan 31 '13 at 10:04
  • It may help you..http://stackoverflow.com/questions/25805643/uipopovercontroller-not-presenting-in-ipad-ios-8/25807599#25807599 – Abhijith Sep 12 '14 at 12:05