【问题标题】:application crashed when open camera打开相机时应用程序崩溃
【发布时间】:2020-01-23 16:39:52
【问题描述】:

我在我的应用程序中使用https://github.com/ivpusic/react-native-image-crop-picker,当相机打开时我可以拍照,但是当我想选择它时,应用程序崩溃,有时一旦打开相机它就会崩溃,但是当我使用调试模式时它可以工作而是在 android 上在所有情况下都运行良好。

当我从 xcode 运行项目时工作正常,但不适用于 react-native run-ios --device "myDeviceName"

同样适用于更高版本的 ios,例如 13,它也能正常工作

  • react-native-image-crop-picker ^0.23.1
  • react-native v0.59.0
  • IOS 9.3.6

调用打开相机时的组件:

ImagePicker.openCamera({
          cropping: true,
          width: 500,
          height: 500,
          includeExif: true,
          includeBase64: true,
          mediaType:"photo"
        })
          .then(image => {
            this.setState({
              cameraOpened: false
            });
            this.props.navigation.navigate("Preview", {
              picture: image,
              type: this.type,
              state: this.props.navigation.state,
              userId: this.userId
            });
          })
          .catch(e => {
            console.log(e);
            this.setState({
              cameraOpened: false
            });
            this.props.navigation.goBack();
          });
      }

Preview.js:

ImageEditor.cropImage(
          this.picture.path,
          {
            offset: { x: 0, y: 0 },
            size: { width: 500, height: 500 },
            displaySize: { width: 500, height: 500 }
          },
          res => {
            // Change it to res
            this._uploadPicture(this.picture.path, response => {
              if (response.status == 200) {
                this.props.savePicture(this.picture);
                this.setState(
                  {
                    loading: false
                  },
                  () => {
                    this.navigation.goBack(key);
                  }
                );
              } else {
                alert(response);
              }
            });
          },
          err => {
            this.setState({
              loading: false
            });
            alert(err);
          }
        );

有什么想法吗?谢谢

【问题讨论】:

    标签: ios react-native


    【解决方案1】:

    稍晚一点,但对于期货搜索者来说:

    我遇到了同样的问题,即使在 Info.plist 中添加了 NSPhotoLibraryAddUsageDescriptionNSPhotoLibraryUsageDescriptionNSMicrophoneUsageDescriptionNSCameraUsageDescription,我收到一封来自 Apple Store connect 的电子邮件,内容是“Info.plist 中缺少目的字符串”。

    这次我错过了“NSAppleMusicUsageDescription”。我不确定为什么我需要这个属性,因为我的应用中没有音乐,但它对我有用。

    【讨论】:

    • 对我没有帮助:(
    猜你喜欢
    • 2018-03-21
    • 2018-08-03
    • 2021-11-19
    • 2015-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多