首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIImagePickerController相机在翻转和取消几次时结冰

UIImagePickerController相机在翻转和取消几次时结冰
EN

Stack Overflow用户
提问于 2014-04-09 23:01:26
回答 1查看 513关注 0票数 1

你好,我在一个有摄像头的应用程序工作。

我可以正确地打开和使用相机。但我发现一只虫子:

当我打开相机,翻转相机,再次翻转相机,然后按取消键。做几次(3-5次)。再次打开相机,我有一个黑色冻结屏幕几秒钟,如果你拍一张照片,看到图像,但屏幕继续黑色。几秒钟后,相机再次出现,您可以继续正常的行为。但我找不到解决办法。

我在网上搜索了很多,找到了一些答案,但没有解决我的问题。

这里有一个类似的问题,但这个解决方案对我没有用:

此外,我还使用DejalBezelActivityView创建带有标签DejalBezelActivityView的旋转区域。

有什么想法吗?

我有我的.h声明:

代码语言:javascript
复制
@property (nonatomic, strong) UIImagePickerController* picker;

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

我的.mm代码:

代码语言:javascript
复制
@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作为一个单例:

代码语言:javascript
复制
-(UIImagePickerController *) imagePicker{
if(!_imagePicker){
   _imagePicker = [[UIImagePickerController alloc] init];
   _imagePicker.delegate = self;
   if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
       _imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
   }
   else{
       _imagePicker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;
   }  
}
return _imagePicker;
}

问题依然存在。

EN

回答 1

Stack Overflow用户

发布于 2014-05-21 00:36:24

这是一个非常晚的响应,但对于那些仍然在努力解决这个问题的人:我注意到,当某个东西备份主线程或影响单独线程上的图形上下文时,似乎会发生这种情况。那里可能是开始寻找的地方。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22975555

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档