图像选择器-离子本机组件

时间:2018-07-09 22:56:03

标签: angular cordova ionic-framework

我正在尝试使用this图像选择器源从设备相机胶卷中选择多张图像(25张以上),但是在尝试访问图库时出现错误。因此,我实际上只有一个按钮,它可以在下面启动此功能,并且我会立即收到错误消息。

这是图像选择器代码

 private openGallery (): void {
    let options = {
      width: 500,
      height: 500,
      quality: 75
    }

    this.imagePicker.requestReadPermission().then(res=> {
      console.log("res" + res);
      this.imagePicker.getPictures(options).then(
        file_uris => console.log(file_uris),
        err => console.log('CHEESE', err)
      );
    });
  }

以下是控制台记录的错误:

  1. 方法:'sudo ionic cordova run browser'

    错误:

  

cordova.js:1003错误:找不到:: ImagePicker ::的exec代理::   getPictures home.ts:81 CHEESE缺少命令错误

  1. 方法:“ ionic serve
    • 返回错误且不进入图库

故障排除 -删除并重新安装节点模块 -删除并重新安装图像选择器 -确保插件的最新版本 -package.json中已验证的插件 -在iOS和Android上测试 -尝试更改代码,请求权限等。

没有运气。有关检查插件是否已正确安装和配置的更多高级调试。

  

错误:plugin_not_installed

有关版本参考,请参见package.json

{   "name": "IonicAngularFire",   "version": "0.0.1",   "author": "Ionic Framework",   "homepage": "http://ionicframework.com/",   "private": true,   "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"   },   "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/camera": "^4.8.0",
    "@ionic-native/core": "4.8.0",
    "@ionic-native/image-picker": "^4.9.0",
    "@ionic-native/splash-screen": "4.8.0",
    "@ionic-native/status-bar": "4.8.0",
    "@ionic/storage": "2.1.3",
    "angularfire2": "^5.0.0-rc.11",
    "cordova-browser": "5.0.3",
    "cordova-ios": "4.5.4",
    "cordova-plugin-camera": "^4.0.3",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-image-picker": "^1.1.3",
    "cordova-plugin-ionic-keyboard": "^2.0.5",
    "cordova-plugin-ionic-webview": "^1.1.19",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-telerik-imagepicker": "^2.2.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "firebase": "^5.1.0",
    "ionic-angular": "3.9.2",
    "ionic-native": "^2.9.0",
    "ionicons": "3.0.0",
    "rxjs": "^6.2.1",
    "rxjs-compat": "^6.2.1",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.26"   },   "devDependencies": {
    "@ionic/app-scripts": "3.1.10",
    "typescript": "~2.6.2"   },   "description": "An Ionic project",   "cordova": {
    "plugins": {
      "cordova-plugin-camera": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-telerik-imagepicker": {
        "PHOTO_LIBRARY_USAGE_DESCRIPTION": "your usage message"
      },
      "cordova-plugin-image-picker": {}
    },
    "platforms": [
      "browser",
      "ios"
    ]   } }

我一直在寻找替代方案或解决方案,但发现的结论大多过时了。任何建议表示赞赏。我目前正在使用离子本机相机插件来获取图像,但是我的应用程序目的是要上传25张以上的图像,因此单张图像的选择并不理想。

同样,这是我正在使用的离子本机组件和github源码-

https://ionicframework.com/docs/native/image-picker/

https://github.com/wymsee/cordova-imagePicker

更新:

  1. Xcode模拟器(成功!!!!) 我继续为iOS开发了我的应用程序,并在Xcode模拟器上运行了它,哇!有用!

我不确定这是否理想,但至少现在我知道它工作正常。我将继续调试以查看它是否可以达到我的目的并发布更新。

最终更新:    显然,ionic本地图像选择器不能在iOS或Android的ionic dev应用程序上运行,但是可以在Xcode模拟器的生产环境中运行(未经Android模拟器测试,但我确定类似的结果)。由于通过Xcode进行调试非常乏味,因此我将继续从事其他工作。

07/13/18使用离子3角5

1 个答案:

答案 0 :(得分:0)

 let options = {
      width: 500,
      height: 500,
      quality: 75,
      maximumImagesCount: 10
    }

add -    maximumImagesCount: 10