iOS ImagePicker存在问题。它工作正常,但是当我想拍摄另一张照片时,相机会加载很长时间(第一次:1-2秒,第二次和之后:8-10秒)。这就是我使用它的方式:
- (void)takePhoto {
_imagePicker = [UIImagePickerController new];
_imagePicker.delegate = self;
_imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
_imagePicker.allowsEditing = NO;
[self presentViewController:_imagePicker animated:YES completion:nil];
}
这就是我获取图片的方式:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
[_imagePickerView.imageView setImage:image];
}
我没有看到错误的地方。当然,我实现了协议UIImagePickerControllerDelegate
和UINavigationControllerDelegate
。
您有什么想法我如何弄清楚导致这种情况的原因?
答案 0 :(得分:0)
您可能希望在通过调用
选择项目后解除UIImagePickerController[_imagePicker dismissViewControllerAnimated:YES completion:nil];
现在应该没事了。
答案 1 :(得分:0)
尝试更改您的第一个代码块,以重复使用已初始化的相同imagePicker:
- (void)takePhoto {
if(_imagePicker == nil)
_imagePicker = [UIImagePickerController new];
_imagePicker.delegate = self;
_imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
_imagePicker.allowsEditing = NO;
[self presentViewController:_imagePicker animated:YES completion:nil];
}