【发布时间】:2016-11-06 08:41:42
【问题描述】:
我想用AVCaptureStillImageOutput拍摄静止图像,当调整焦点完成时,我正在使用键值观察来做到这一点,在iOS 10的iPhone 6+上测试时方法
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if( [keyPath isEqualToString:@"adjustingFocus"] )
{
BOOL adjustingFocus = [ [change objectForKey:NSKeyValueChangeNewKey] isEqualToNumber:[NSNumber numberWithInt:1] ];
if (adjustingFocus)
{
NSLog(@"adjusting focus started");
}
else
{
NSLog(@"adjustingFocus done");
}
}
}
有时会被调用多次,当我第一次检测到对焦完成时,屏幕很模糊,捕获的静止图像也是如此。我注意到在这种情况下(模糊图像)该方法被调用了 2 次(在开始和结束调整焦点时)。有没有办法检测到焦点没有正确调整并等待下一次调用或只调用一次的方法?
【问题讨论】:
标签: ios iphone key-value-observing avcapturesession