2014-04-09 30 views
1

你好,我在相機應用程序正在處理。相機的UIImagePickerController凍結時翻轉並取消了幾次

我可以打開並正確使用相機。但我發現了一個錯誤:

當我打開相機,翻轉相機,再翻轉相機,然後按取消。做幾次(3 - 5)。再次打開相機,我有一個黑色的凍結屏幕幾秒鐘,如果你拍照,看到圖像,但屏幕繼續黑色。幾秒鐘後,相機再次出現,您可以繼續正常行爲。但我找不到解決辦法。

我搜索了很多在互聯網和找到一些答案,但沒有解決我的問題。

這裏類似的問題,但對我來說,解決沒有工作:

而且我用DejalBezelActivityView創建一個微調區域標籤爲DejalBezelActivityView

有什麼想法?

我有我的.h聲明:

@property (nonatomic, strong) UIImagePickerController* picker; 

- (void) takePhoto: (id)vc; 
- (void) selectPhoto: (id)vc; 

而且我.mm代碼:

@synthesize picker = _picker; 

- (id) init{ 
self = [super init]; 

if (self){ 
    self.picker = [[UIImagePickerController alloc] init]; 

} 
return self; 
} 



- (void)takePhoto:(id)vc{ 
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){ 
    [VC_Camera showAlert]; 
    return; 
} 

[self init]; 
self.picker.delegate = self; 
self.picker.allowsEditing = YES; 
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
self.picker.cameraDevice = UIImagePickerControllerCameraDeviceRear; 

[[VC_Camera getMainWindow] presentViewController:self.picker animated:YES completion:NULL]; 
} 

- (void)selectPhoto:(id)vc{ 
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]){ 
    [VC_Camera showAlert]; 
    return; 
} 

[self init];  
self.picker.delegate = self; 
self.picker.allowsEditing = YES; 
self.picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 

[[VC_Camera getMainWindow] presentViewController:self.picker animated:YES completion:NULL]; 
} 

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { 

self.picker = picker; 

DejalActivityView * _activityView = [DejalBezelActivityView activityViewForView:[[UIApplication sharedApplication] keyWindow] withLabel:@"Loading"]; 

    [self performSelector:@selector(cancelAfterDelay:) withObject:@{@"DejalAV":_activityView} afterDelay:1.0]; 

} 


- (void) cancelAfterDelay:(NSDictionary*) dict 
{ 

DejalActivityView* _activityView = [dict objectForKey:@"DejalAV"]; 

[DejalBezelActivityView removeViewAnimated:YES]; 

[self.picker dismissViewControllerAnimated:YES completion:nil]; 
} 

感謝:d

[更新]

我嘗試使用UIImagePickerController作爲單例:

-(UIImagePickerController *) imagePicker{ 
if(!_imagePicker){ 
    _imagePicker = [[UIImagePickerController alloc] init]; 
    _imagePicker.delegate = self; 
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){ 
     _imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
    } 
    else{ 
     _imagePicker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary; 
    } 
} 
return _imagePicker; 
} 

和問題仍然存在。

回答

0

這是一個很遲了迴應,但對於那些與這個問題仍然摔跤:我注意到這似乎當事情或者是備份主線程,或影響一個單獨的線程圖形上下文的情況發生。那些可能是開始尋找的地方。