【发布时间】:2019-07-22 17:04:56
【问题描述】:
我正在尝试使用 react-native-image-picker,但出现错误:NativeModule.ImagePickermanager is null。
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模拟器。
【问题讨论】:
-
您找到解决方案了吗?
标签: react-native react-native-image-picker