当按下从前向后翻转相机的按钮时,我的 UIImagePickerController 冻结并且相机关闭。这就是我如何从方法中初始化项目中的图像选择器控制器对象(省略其余代码),因为它与 UIimagepickercontroller 对象无关。
//In my .h file
UIImagePickerController * imgPicker;
//in my .m file
-(void)viewDidLoad {
imgPicker = [[UIImagePickerController alloc] init];
imgPicker.delegate = self;
imgPicker.allowsEditing = YES;
}
-(void) takePicture {
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:imgPicker animated:YES completion:NULL];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
masterImage.image = [info objectForKey:UIImagePickerControllerEditedImage];
if(masterImage.image == nil) {
masterImage.image = [info objectForKey:UIImagePickerControllerEditedImage];
}
[self dismissModalViewControllerAnimated:YES];
}
-(void) imagePickerControllerDidCancel:(UIImagePickerController *)picker{
[self dismissModalViewControllerAnimated:YES];
}
-(void) releaseOutlets {
[imgPicker release];
}