gpt4 book ai didi

javascript - 获取 "Illegal callback invocation from native module. This callback type only permits a single invocation from native code"

转载 作者:行者123 更新时间:2023-11-28 03:37:42 36 4
gpt4 key购买 nike

我在两个类中使用react-native-image picker和react-native-image-crop picker库。

一个是启动库图像(react-native-image picker),另一个包打开裁剪窗口(react-native-image-crop-picker)。

此处,启动库位于一个屏幕中,并且在从另一个屏幕上的库导航时打开裁剪器。

我的问题是,点击选择的裁剪窗口后,它再次重置裁剪窗口,需要再次裁剪,然后出现非法调用错误。

引用代码sniipet

 // Opens the library image in Library.js screen
import ImagePicker from 'react-native-image-picker';
ImagePicker.launchImageLibrary(options, (response) => {
if (response.didCancel) {
console.warn('User cancelled photo picker');
}
else if (response.error) {
console.warn('ImagePicker Error: ', response.error);
}
else {
this.props.navigation.navigate('CropWindow', { screenName: 'CropImage',uri: response.uri});
}

下面是CropWindow.js中的裁剪窗口

import ImagePicker from 'react-native-image-crop-picker';
ImagePicker.openCropper({
path: response,
width: deviceWidth,
height: deviceWidth*5/4
}).then(image => {
this.props.navigation.navigate('ShowAllCroppedImage', {uri: response.uri, croppedImage: this.croppedImage.bind(this)});
})
.catch((err) => {
console.log("openCropper error = " + err)
});

enter image description here

最佳答案

Android 权限问题

import { PermissionsAndroid } from 'react-native';

async requestCameraPermission() {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.CAMERA,
{
'title': 'Cool Photo App Camera Permission',
'message': 'Cool Photo App needs access to your camera ' +
'so you can take awesome pictures.'
}
)
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("You can use the camera")
} else {
console.log("Camera permission denied")
}
} catch (err) {
console.warn(err)
}
}

关于javascript - 获取 "Illegal callback invocation from native module. This callback type only permits a single invocation from native code",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57573723/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com