我正在尝试使用react-native-image-picker,但出现错误:NativeModule.ImagePickermanager为空。
import React, { Component } from 'react';
import { Text, View, StyleSheet, Alert, PixelRatio, Image } from 'react-native';
import ImagePicker from 'react-native-image-picker';
...
handleChoosePhoto = () => {
const options = {
noData: true,
};
ImagePicker.launchImageLibrary(options, response => {
if (response.uri) {
this.setState({ photo: response });
}
});
};
...
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
{this.state.photo && (
<Image
source={{ uri: this.state.photo.uri }}
style={{ width: 300, height: 300 }}
/>
)}
<Button title="Choose Photo" onPress={this.handleChoosePhoto} />
</View>
我尝试运行react-native link react-native-image-picker
。当我运行此命令时,什么都没有发生。它在终端中不显示任何内容。我正在使用IOS模拟器。
答案 0 :(得分:1)
最近8个小时以来,我一直在尝试解决此错误,但无法成功。请使用expo中的ImagePicker,这是其链接。 https://docs.expo.io/versions/latest/sdk/imagepicker/ 它将解决您的错误。
答案 1 :(得分:0)
我也有同样的问题。这就是对我有用的。
卸载最新版本 npm卸载react-native-image-picker 安装版本0.28.0 npm install react-native-image-picker@0.28.0-保存 react-native链接react-native-image-picker