zoukankan      html  css  js  c++  java
  • IOS 监听相机对焦事件

     

    来自官方文档:

    You can use the adjustingFocus property to determine whether a device is currently focusing. You can observe the property using key-value observing to be notified when a device starts and stops focusing.

     

    来自StackoverFlow:

    // callback
    -(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]];
           
    NSLog(@"Is adjusting focus? %@", adjustingFocus ?@"YES":@"NO");
           
    NSLog(@"Change dictionary: %@", change);
       
    }
    }

    // register observer
    -(void)viewWillAppear:(BOOL)animated{
       
    AVCaptureDevice*camDevice =[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
       
    int flags =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"];

       
    (...)
    }
  • 相关阅读:
    MongoDB
    前端框架之vue初步学习
    mysql再回首
    oracle之回顾二
    oracle再回首
    springboot之对之前的补充
    springCloud学习
    springboot-ssm的pom.xml
    MyCat
    11.Java反射机制 哦对了,前面的序号来自随笔关于编程之路的思索第一篇
  • 原文地址:https://www.cnblogs.com/cokecoffe/p/2598955.html
Copyright © 2011-2022 走看看