UIImagePickerController在相机翻转时冻结 [英] UIImagePickerController Freezes when camera flips
本文介绍了UIImagePickerController在相机翻转时冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当按下从前向后翻转相机的按钮时,我的UIImagePickerController冻结并且相机关闭.这就是我从方法中初始化项目中的图像选择器控制器对象(其余代码被省略)的方式,因为它与UIimagepickercontroller对象无关.
My UIImagePickerController freezes and the camera closes when the button to flip the camera from front to back is pressed. This is how I initialize the image picker controller object within the project (the rest of the code was ommitted) from the methods as it is irrelevant to the UIimagepickercontroller object.
//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];
}
推荐答案
就规则而言,更改代码.代替:
Just for rule, change your code. Instead of:
UIImagePickerController * imgPicker;
写入.h文件:
@property (nonatomic, strong) UIImagePickerController * imgPicker;
而不是将其合成到您的.m文件中:
than synthesize it in your .m file:
imgPicker = _imgPicker;
接下来,每次对该属性的调用都将用self进行调用.
and next every call to this property call with self.
这篇关于UIImagePickerController在相机翻转时冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文