我正在尝试使用 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模拟器。