Camera Autofocus observer?
I find the solution for my case to find when autofocus starts/ends. It ' s simply dealing with KVO (Key-value observing).
In my Uiviewcontroller:
has been verified. Original address: Http://stackoverflow.com/questions/9100357/iphone-camera-autofocus-observer
//Callback- (void) Observevalueforkeypath: (NSString *) KeyPath Ofobject: (ID)ObjectChange: (nsdictionary *) Change context: (void*) Context {if([KeyPath isequaltostring:@"Adjustingfocus"]) {BOOL Adjustingfocus= [[Change Objectforkey:nskeyvaluechangenewkey] isequaltonumber:[nsnumber numberwithint:1] ]; NSLog (@"Is adjusting focus?%@", Adjustingfocus?@"YES":@"NO" ); NSLog (@"Change dictionary:%@", change); }}//Register Observer- (void) Viewwillappear: (BOOL) animated{Avcapturedevice*camdevice =[Avcapturedevice Defaultdevicewithmediatype:avmediatypevideo]; intFlags =nskeyvalueobservingoptionnew; [Camdevice addobserver:self Forkeypath:@"Adjustingfocus"Options:flags Context:nil]; (...) }//Unregister Observer- (void) Viewwilldisappear: (BOOL) animated{Avcapturedevice*camdevice =[Avcapturedevice Defaultdevicewithmediatype:avmediatypevideo]; [Camdevice removeobserver:self Forkeypath:@"Adjustingfocus"]; (...)}
iOS development, camera focus status monitoring