1

当我尝试使用 react-native-image-picker 访问照片时,它返回错误'null 不是对象(评估'ImagePickerManager.showImagePicker')'。

我已经尝试链接库删除节点模块,然后再次等,但没有一个工作。

const ImagePicker = require("react-native-image-picker");

<TouchableOpacity
                    onPress={() => {
                        const options = {
                            title: "Select Profile Pic",
                            mediaType: "photo",
                            takePhotoButtonTitle: "Take a Photo",
                            maxWidth: 256,
                            maxHeight: 256,
                            allowsEditing: true,
                            noData: true
                        }
                    ImagePicker.showImagePicker(options, response => {
                        if (response.uri){
                            this.setState({photo: response})
                        }

                        })


firebase.storage.ref().child(`chatImg/${this.state.photo.uri}`);
                    }}
                    style={{ flexDirection: 'row' }}
                >
                    <View style={{ width: 15 }} />
                    <AutoHeightImage width={35} source= 
{require('../../resource/icon_attach.png')} />                    
                    <View style={{ width: 5 }} />
                </TouchableOpacity>
4

3 回答 3

0

将 RNImagePicker.xcodeproj 手动添加到 xcode 解决了我的问题。

于 2019-04-05T09:37:01.773 回答
0

我认为当前版本存在错误。我遇到过这种情况,我所做的是卸载 image-picker 包上的当前版本,并安装了版本@1.1.0

npm uninstall react-native-image-picker

npm install react-native-image-picker@1.1.0 --save

react-native link react-native-image-picker

cd ios

pod install

cd ..

停止您的 Packager 或 Bundler 并重新运行它

npm start --rest-cache

于 2019-12-12T06:50:01.723 回答
0

卸载最新版本 npm uninstall react-native-image-picker 已安装版本 0.28.0 npm install react-native-image-picker@0.28.0 --save react-native link react-native-image-picker

于 2021-02-26T02:12:58.063 回答