我已经在这个问题上花了大约3天的时间,我已经尝试了我力所能及的一切。
React Native给我这个错误
react-native-image-picker : NativeModule.ImagePickermanger is Null. To fix this issue, try these steps;
Run react-native link react-native-image-picker in the project root.
Rebuild and re-run the App.当我运行react-native link react-native-image-picker时,我得到;
info iOS module "react-native-image-picker" is already linked
info Android module "react-native-image-picker" is already linked当我使用react-native重新构建时
react-native run-android 并重新运行
npm start ( as shown on the screen), 它会返回到最初的错误。它就像一个循环。
我在Ubuntu 16.04上使用Andrioid Emulator Nexus 7
代码片段
import { ImagePicker } from 'react-native-image-picker';
_pickImage = () => {
const options = {
noData: true,
allowsEditing: true,
mediaTypes: "mixed",
quality: 0.5,
};
ImagePicker.launchImageLibrary(options, response => {
if (response.uri) {
let fileObj = {
key: this.state.attachments.length, //first image will have 0 here
fileInfo: response
};
this.state.attachments.push(fileObj);
this.setState((prevState) => ({
numFiles: parseInt(prevState.numFiles) + 1,
}))
}
});
};
_pickLiveImage = () => {
const options = {
noData: true,
allowsEditing: true,
mediaTypes: "mixed",
quality: 0.5,
};
ImagePicker.launchCamera(options, response => {
if (response.uri) {
let fileObj = {
key: this.state.attachments.length, //first image will have 0 here
fileInfo: response
};
this.state.attachments.push(fileObj);
this.setState((prevState) => ({
numFiles: parseInt(prevState.numFiles) + 1,
}))
}
});
};在这个问题上的任何帮助或建议都将受到高度欢迎。
发布于 2019-09-30 19:48:10
我试过了,它工作得非常完美。当你
RN >= 0.60
cd ios & pod安装
RN < 0.60
react-native链接react-native-image选取器
https://stackoverflow.com/questions/57135847
复制相似问题