【发布时间】:2011-10-27 16:52:43
【问题描述】:
自 iOS 4 起,我使用以下方法设置焦点:
- (void) focusAtPoint:(CGPoint)point
{
AVCaptureDevice *device = [[self captureInput] device];
NSError *error;
if ([device isFocusModeSupported:AVCaptureFocusModeAutoFocus] &&
[device isFocusPointOfInterestSupported])
{
if ([device lockForConfiguration:&error]) {
[device setFocusPointOfInterest:point];
[device setFocusMode:AVCaptureFocusModeAutoFocus];
[device unlockForConfiguration];
} else {
NSLog(@"Error: %@", error);
}
}
}
在 iOS 4 设备上,这可以正常工作。但在 iOS 5 上,实时摄像头画面冻结,几秒钟后完全变黑。没有抛出异常或错误。
如果我注释掉 setFocusPointOfInterest 或 setFocusMode,则不会发生错误。所以两者结合会导致这种行为。
【问题讨论】:
-
我在 iOS 5 上使用完全相同的代码,没有任何问题。你的错误可能在其他地方吗?
标签: ios ios5 avcapturedevice avcapture