【问题标题】:returns an error 'null is not an object (evaluating 'imagepickermanager.showimagepicker')' while calling method onpress在调用方法 onpress 时返回错误“null 不是对象(评估 'imagepickermanager.showimagepicker')”
【发布时间】:2019-04-05 05:18:13
【问题描述】:

当我尝试使用 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>

【问题讨论】:

    标签: react-native react-native-image-picker


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      我认为当前版本存在错误。我遇到过这种情况,我所做的就是卸载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

      【讨论】:

        【解决方案3】:

        卸载最新版本 npm 卸载 react-native-image-picker 安装版本 0.28.0 npm install react-native-image-picker@0.28.0 --save react-native 链接 react-native-image-picker

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-01-05
          相关资源
          最近更新 更多