camera.getPicture在选择画廊的cordova ios中落后了太多时间

时间:2015-04-13 10:09:49

标签: ios cordova cordova-plugins cordova-3

我使用了cordova相机插件从ios中的图库中获取图片,对我而言,图片库文件显示速度不快,需要花费太多时间来加载... 我只使用以下代码。它的工作,但它需要太多的时间来加载Photolibrary和另外一件事是savetoPhotoAlbum不工作。 但对于Android这两个工作正常,它只在iOS上滞后

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

请帮助我......

1 个答案:

答案 0 :(得分:3)

在选项中提供“ 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));
    });