-1

I have a problem with iOS ImagePicker. It works correctly, but when I want to take another photo the camera loads for a very long time (first time: 1-2sec, second time and later: 8-10sec). This is how I use it:

- (void)takePhoto {
    _imagePicker = [UIImagePickerController new];
    _imagePicker.delegate = self;
    _imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    _imagePicker.allowsEditing = NO;
    [self presentViewController:_imagePicker animated:YES completion:nil];
}

and this is how I get the image:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
    [_imagePickerView.imageView setImage:image];
}

I don't see there much place for bugs. Of course I implement protocols UIImagePickerControllerDelegate and UINavigationControllerDelegate.

Do you have any ideas how can I figure out what is causing this?

Noor
  • 2,071
  • 19
  • 28
KlimczakM
  • 12,576
  • 11
  • 64
  • 83
  • 1
    Look at this [question](http://stackoverflow.com/questions/19061510/memory-warning-uiimagepickercontroller-ios-7). It has to do with very large images you are loading with ``imagePickerController``. You should scale them down. – damirstuhec Mar 05 '14 at 10:15

2 Answers2

0

You may want to dismiss the UIImagePickerController after you picked an item by calling

[_imagePicker dismissViewControllerAnimated:YES completion:nil];

It should be fine, now.

Benjamin Clanet
  • 1,076
  • 3
  • 10
  • 17
0

Try changing your first block of code to reuse the same imagePicker you have already initialized:

- (void)takePhoto {
    if(_imagePicker == nil)
        _imagePicker = [UIImagePickerController new];
    _imagePicker.delegate = self;
    _imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    _imagePicker.allowsEditing = NO;
    [self presentViewController:_imagePicker animated:YES completion:nil];
}
gWiz
  • 1,274
  • 9
  • 12