在 QRcodeScanner React Native 中打开/关闭手电筒 [英] Turn flashlight on/off In QRcodeScanner React native

查看:84
本文介绍了在 QRcodeScanner React Native 中打开/关闭手电筒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 react-native-qrcode-scanner 而我想要做的是:当用户按下手电筒图标 flashLight 时我这样做了:

im using react-native-qrcode-scanner and what i want to do is : when user press on a flashlight icon flashLight go on i done this :

<QRCodeScanner
        showMarker
        onRead={this.onSuccess.bind(this)}
        cameraStyle={{ height: SCREEN_HEIGHT }}
        cameraProps={{ flashMode: this.state.flashLight ? RNCamera.Constants.FlashMode.on : RNCamera.Constants.FlashMode.off, captureAudio: false }}

相机道具作品但是当我改变 state.flashLight (true or false) flashLight 不会改变

camera prop works but when i change the state.flashLight (true or false) the flashLight not change

知道如何根据状态改变相机道具吗??

any Idea how change camera prop with state ??

推荐答案

尝试替换:

RNCamera.Constants.FlashMode.on

与:

RNCamera.Constants.FlashMode.torch

手电筒现在打开了吗?

这篇关于在 QRcodeScanner React Native 中打开/关闭手电筒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆