[英]takePictureAsync of Expo's Camera returns nothing. (Promise never fulfilled)
我开始使用来自 Expo 的Camera
进行 React Native( https://docs.expo.io/versions/v35.0.0/sdk/camera/ )
我看到相机 window 但是当我调用await this.camera.takePictureAsync();
Promise 从未完成,我没有得到 output。
我的照相机:
<Camera ref={(camera) => this.camera = camera}
style={{flex: 1}}
type={this.state.type}
>
<Button onPress={() => this.snap()} title='SNAP'/>
</Camera>
卡扣 function:
snap = async () => {
if (this.camera) {
console.log("SNAP!");
let photo = await this.camera.takePictureAsync();
console.log(photo);
}
};
SNAP!
显示在控制台中,因此相机本身没有问题。 第二个console.log
永远不会被调用。
我正在 Android 9(真实设备)上测试我的应用程序
编辑:它正在模拟器上工作,所以真实设备肯定有问题
尝试将相机元素的 useCamera2Api 属性设置为 true。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.