您好我在使用相机的应用中工作。
我可以正确打开并使用相机。但我发现了一个错误:
当我打开相机时,翻转相机,再次翻转相机并按取消。做几次(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
[UPDATE]
我尝试将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 :(得分:0)
这是一个非常晚的响应,但对于那些仍在努力解决这个问题的人:我注意到,当某些东西要么备份主线程,要么影响单独线程上的图形上下文时,这似乎就会发生。那些可能是开始寻找的地方。