ImagePicker第二次加载很长时间

时间:2014-03-05 10:12:46

标签: ios iphone uiimagepickercontroller

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];
}

我没有看到错误的地方。当然,我实现了协议UIImagePickerControllerDelegateUINavigationControllerDelegate

您有什么想法我如何弄清楚导致这种情况的原因?

2 个答案:

答案 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];
}