世博会,React Native takePictureAsync 不会 return
Expo, React Native takePictureAsync does not return
我几乎直接从 docs 中的代码片段使用 expo-camera
而 takePictureAsync
函数从不 returns.
async takePicture () {
try {
let photo = await this.camera.takePictureAsync()
console.log('this will never return', photo)
} catch (err) {
console.error('this does not error', err)
}
}
我已经授予许可,并且我已经测试了各种方法,这可能是一个承诺问题,但没有成功。
我 运行 在设备上使用 Pixel 3a。如有任何建议,我们将不胜感激。
它接受一个选项对象作为必需的参数。
quality (number) -- Specify the quality of compression, from 0 to 1. 0
means compress for small size, 1 means compress for maximum quality.
exif (boolean) -- Whether to also include the EXIF data for the image.
onPictureSaved (function) -- A callback invoked when picture is saved.
If set, the promise of this method will resolve immediately with no
data after picture is captured. The data that it should contain will
be passed to this callback. If displaying or processing a captured
photo right after taking it is not your case, this callback lets you
skip waiting for it to be saved.
skipProcessing (boolean) - Android only. If set to true, camera skips
orientation adjustment and returns an image straight from the device's
camera. If enabled, quality option is discarded (processing pipeline
is skipped as a whole). Although enabling this option reduces image
delivery time significantly, it may cause the image to appear in a
wrong orientation in the Image component (at the time of writing, it
does not respect EXIF orientation of the images).
我几乎直接从 docs 中的代码片段使用 expo-camera
而 takePictureAsync
函数从不 returns.
async takePicture () {
try {
let photo = await this.camera.takePictureAsync()
console.log('this will never return', photo)
} catch (err) {
console.error('this does not error', err)
}
}
我已经授予许可,并且我已经测试了各种方法,这可能是一个承诺问题,但没有成功。
我 运行 在设备上使用 Pixel 3a。如有任何建议,我们将不胜感激。
它接受一个选项对象作为必需的参数。
quality (number) -- Specify the quality of compression, from 0 to 1. 0 means compress for small size, 1 means compress for maximum quality.
exif (boolean) -- Whether to also include the EXIF data for the image.
onPictureSaved (function) -- A callback invoked when picture is saved. If set, the promise of this method will resolve immediately with no data after picture is captured. The data that it should contain will be passed to this callback. If displaying or processing a captured photo right after taking it is not your case, this callback lets you skip waiting for it to be saved.
skipProcessing (boolean) - Android only. If set to true, camera skips orientation adjustment and returns an image straight from the device's camera. If enabled, quality option is discarded (processing pipeline is skipped as a whole). Although enabling this option reduces image delivery time significantly, it may cause the image to appear in a wrong orientation in the Image component (at the time of writing, it does not respect EXIF orientation of the images).