【问题标题】:Image Picker - Ionic Native Component图像选择器 - 离子原生组件
【发布时间】:2018-12-17 16:47:55
【问题描述】:

我正在尝试使用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 :: 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 模拟器上运行它,哇!有用!

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

最终更新: 很明显,离子原生图像选择器不适用于 iOS 或 Android 的 ionic 开发应用程序,但它在 Xcode 模拟器上的生产中工作(未针对 android 模拟器进行测试,但我确信结果相似)。由于通过 Xcode 进行调试很乏味,因此我将从事其他工作。

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

【问题讨论】:

  • 首先,Image Picker 插件 (ionicframework.com/docs/native/image-picker) 仅支持 iOS 和 Android(不在浏览器中)。因此,您应该在 iOS 或 Android 上对其进行测试。对于 Android 平台,您可以使用命令ionic cordova run android 运行应用程序。
  • @DanilProkhorenko 感谢您的建议,我将继续专门在移动平台上进行测试。

标签: angular cordova ionic-framework


【解决方案1】:
 let options = {
      width: 500,
      height: 500,
      quality: 75,
      maximumImagesCount: 10
    }

add -    maximumImagesCount: 10

【讨论】:

  • 添加说明。
猜你喜欢
  • 2019-11-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-19
  • 1970-01-01
  • 1970-01-01
  • 2019-06-14
  • 1970-01-01
相关资源
最近更新 更多