zoukankan      html  css  js  c++  java
  • ios开发之手电筒使用补充

    今天看自己之前的scanning,发现对于照明说的不是很清楚,这里重新写一次,也做收藏

    #import <AVFoundation/AVFoundation.h>   //需要引用框架

    - (void)lightSwitch:isOn{

    AVCaptureDevice *captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; //创建Video类型的驱动对象用于启动手电筒

       if (![captureDevice hasTorch]) return;  //检测是否有灯光

        if(![captureDevice hasFlash])  return; //检测是否有灯光

        [captureDevice lockForConfiguration:nil];

    //  官方解释,必须要持一个设备锁  --------In order to set hardware properties on an AVCaptureDevice, such as focusMode and exposureMode, clients must first acquire a lock on the device. Clients should only hold the device lock if they require settable device properties to remain unchanged. Holding the device lock unnecessarily may degrade capture quality in other applications sharing the device.

        isOn = !isOn;

        captureDevice.torchMode = isOn? AVCaptureTorchModeOn:AVCaptureTorchModeOff;

        [captureDevice unlockForConfiguration];

    }

    提高技能如同提升自信心。
  • 相关阅读:
    MySQL_创建数据库和表
    MySQL注释的3中方法
    子查询概念和分类
    弱网测试如何进行
    Fiddler_ 移动端抓包配置IOS&Android,Fiddler获取APP端的流量
    Fiddler_HTTPS 如何抓包和浏览器设置
    Fiddler_弱网测试
    Three.js 游戏操作案例
    flex 教程
    JS知识
  • 原文地址:https://www.cnblogs.com/chims-liu-touch/p/6650625.html
Copyright © 2011-2022 走看看