2014-03-05 73 views
-1

我的iOS ImagePicker有問題。它工作正常,但是當我想拍攝另一張照片時,相機會加載很長時間(第一次:1-2秒,第二次和以後:8-10秒)。這是我如何使用它:ImagePicker第二次加載很長

- (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

你有什麼想法我怎麼才能找出是什麼原因造成的?

+1

看看這個[問題](http://stackoverflow.com/questions/19061510/memory-warning-的UIImagePickerController-IOS-7)。它與使用'imagePickerController''加載的非常大的圖像有關。你應該縮小它們。 – damirstuhec

回答

0

您可能要解僱你的UIImagePickerController通過調用

[_imagePicker dismissViewControllerAnimated:YES completion:nil]; 

應該沒事,現在選擇了一個項目之後。

+0

我不是一個問題,我仍然試圖解決它。 – KlimczakM

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

我不是一個問題,我仍然試圖解決它。 – KlimczakM

相關問題