错误:尝试出席

时间:2013-01-31 09:49:43

标签: ios camera uiimagepickercontroller presentation

嘿大家,谢谢你的阅读。我正在制作一个应用程序,您可以从相机胶卷拍摄照片和检索图片并将其显示在视图上。问题是,当我尝试使用启动相机胶卷的按钮时,我会在标题中看到错误“演示正在进行中”。

如果我注释掉代码[self presentViewController:imagePicker animated:YES completion:NULL];在viewdidappear方法中,我可以调出相机卷...我不知道如何正确地解雇这个,我试过[imagePicker dismissViewControllerAnimated:YES completion:NULL];但无济于事。

这是我的代码!谢谢你查一下。

-(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 ++;
}
}

固定(也许)我改变了:

[imagePicker dismissViewControllerAnimated:YES completion:NULL];

[imagePicker dismissViewControllerAnimated:NO completion:NULL];

将动画更改为“否”。 WTF:s

2 个答案:

答案 0 :(得分:4)

将您要执行的代码放在此

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

答案 1 :(得分:0)

它可能对你有所帮助。您正在使用 presentviewcontroller 而不是 presentModalViewController

并且在解雇时也使用 dismissModalViewController