iPhone:是否可以轮询相机是否处于事件状态?

标签 iphone objective-c ios camera

我们正在创建一个照片应用程序,让用户可以连续拍摄多张照片。出于某种原因,相机似乎在没有明显触发的情况下就死机了。如果相机正在运行并且设备处于空闲状态(屏幕保护程序/锁定),或者如果按下 iPhone 主按钮并且应用程序最小化,则通常会出现这种情况。所以我们需要找到一种方法来检查相机是否仍在运行。这可以以某种方式进行投票吗?有人遇到过类似的问题吗?

最佳答案

如果您可以在 self.view 上获得摄像头 View ,您可以说摄像头处于事件状态或存在。这是检查摄像头 View 是否可用的方法 -

UIView *cameraView = [self findCamControlsLayerView:self.view];
if (cameraView)
// camera is present
else
// camera is not present




// Find the view that contains the camera controls (buttons)
- (UIView*)findCamControlsLayerView:(UIView*)view {

Class cl = [view class];
NSString *desc = [cl description];
if ([desc compare:@"PLCropOverlay"] == NSOrderedSame)
return view;

for (NSUInteger i = 0; i < [view.subviews count]; i++)
{
UIView *subView = [view.subviews objectAtIndex:i];
subView = [self findCamControlsLayerView:subView];
if (subView)
return subView;
}

return nil;
}

关于iPhone:是否可以轮询相机是否处于事件状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9051569/

相关文章:

iphone - @Synthesize默认问题

iphone - "Plays Sound"Interface Builder 中 UIButton 的属性

ios - MPMoviePlayerController.view 未从 super View 中删除

ios - 文件是为存档而构建的,这不是正在链接的架构(armv7s)

ios - MPMoviePlayerController 缓冲状态

iphone - 加入多个 ALAC 文件。

iphone - Xcode 4中的 "Deployment target"和 "iOS deployment target"有什么区别

iphone - 创建具有多个图标的 iPhone View (例如 Yelp、旧 Facebook 启动器)

iOS Objective-C 逻辑或键盘类型

ios - UITableView 多个 Action