camera.getPicture 在 Cordova ios 中滞后了太多时间,来自精选图库



我使用 cordova 相机插件从 ios 中的图库中获取图片,对我来说,图片库文件的显示速度不快,加载需要太多时间......我只使用了下面的代码。它的工作,但它需要太多时间来加载照片库,还有一件事是保存相册不起作用。但是对于Android来说,这两个工作正常,仅在iOS上滞后

navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
      quality: 30,     
      allowEdit : false,
      encodingType: Camera.EncodingType.JPEG,
      destinationType: destinationType.DATA_URL,
      sourceType: pictureSource.PHOTOLIBRARY
    }); 

请帮助我任何人...

选项中给出"mediaType"值很重要,例如"mediaType: this.camera.MediaType.PICTURE"。

  getImage(pictureSourceType, crop = true, quality = 50, allowEdit = true, saveToAlbum = true) {
    const options = {
      quality,
      allowEdit,
      destinationType: this.camera.DestinationType.FILE_URI,
      sourceType: pictureSourceType,
      encodingType: this.camera.EncodingType.JPEG,
      saveToPhotoAlbum: saveToAlbum,
      mediaType: this.camera.MediaType.PICTURE
    };
    // If set to crop, restricts the image to a square of 600 by 600
    if (crop) {
      options['targetWidth'] = 600;
      options['targetHeight'] = 600;
    }
    return this.camera.getPicture(options).then(imageData => {
      console.log("test 4");
      const base64Image = imageData;
      return base64Image;
    }, error => {
      console.log('CAMERA ERROR -> ' + JSON.stringify(error));
    });

最新更新