什么时候会发布AVCaptureDeviceSubjectAreaDidChangeNotification?

时间:2015-09-15 09:53:00

标签: ios avfoundation avcapturedevice

在Apple的示例代码“AVCam”中,AVCaptureDeviceSubjectAreaDidChangeNotification被添加到NSNotificationCenter,但在我的测试中从不调用其回调“subjectAreaDidChange”。我想知道这个通知何时会被系统发布?

通过以下代码添加:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(subjectAreaDidChange:)
                                             name:AVCaptureDeviceSubjectAreaDidChangeNotification
                                           object:[[self videoDeviceInput] device]];

AVFoundation的头文件AVCaptureDevice.h如下:

@constant  AVCaptureDeviceSubjectAreaDidChangeNotification
@abstract
   Posted when the instance of AVCaptureDevice has detected a substantial change to the 
   video subject area.
@discussion
   Clients may observe the AVCaptureDeviceSubjectAreaDidChangeNotification to know when an
   instance of AVCaptureDevice has detected a substantial change to the video subject area.
   This notification is only sent if you first set subjectAreaChangeMonitoringEnabled to
   YES.

这就是我的全部问题。非常感谢你。

1 个答案:

答案 0 :(得分:1)

你有没有设置

  

[[self videoDeviceInput] device] .subjectAreaChangeMonitoringEnabled = YES;