Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当使用ImagePicker在android中选择多个图像时,ionic应用程序关闭_Android_Ionic Framework - Fatal编程技术网

当使用ImagePicker在android中选择多个图像时,ionic应用程序关闭

当使用ImagePicker在android中选择多个图像时,ionic应用程序关闭,android,ionic-framework,Android,Ionic Framework,我尝试使用ImagePicker插件在我的ionic应用程序中选择多个图像,当我只选择一个图像时,但如果我选择更多图像,应用程序将关闭 版本 离子型:4.0.3 安卓:7.0.0 图像选择器:2.2.2 代码 } openGallery(){ let选项={ 最大值:10, 宽度:500, 身高:500, 质量:100, 输出类型:1 } 这个.imagePicker.getPictures(选项) 。然后(文件=>{ this.images=新数组(file.length); for(设i

我尝试使用ImagePicker插件在我的ionic应用程序中选择多个图像,当我只选择一个图像时,但如果我选择更多图像,应用程序将关闭

版本

离子型:4.0.3
安卓:7.0.0
图像选择器:2.2.2

代码

}

openGallery(){

let选项={
最大值:10,
宽度:500,
身高:500,
质量:100,
输出类型:1
}
这个.imagePicker.getPictures(选项)
。然后(文件=>{
this.images=新数组(file.length);
for(设i=0;i
}
有关于如何解决此问题的帮助吗?

构造函数(public-navCtrl:NavController,
constructor(public navCtrl: NavController,
    private camera: Camera,
    private transfer: FileTransfer,
    private file: File,
    private fileOpener: FileOpener,
    private loadingCtrl: LoadingController,
    private plt: Platform,
    private imagePicker: ImagePicker,
    private base64: Base64,
    private sanitizer: DomSanitizer) {
    }
    images=[];
    public items: Array<{ images: string;}> = [];
    takePhoto(){
      this.imagePicker.hasReadPermission()
      .then(res => {
        if (res) {
          this.openGallery();
        } else {
          this.imagePicker.requestReadPermission()
          .then(res => {
            if (res === 'ok') {
              this.openGallery();
            }
          })
        }
      })
      .catch(error => console.log(error));
    }
    openGallery () {
      let options = {
        maximumImagesCount: 10,
        correctOrientation: true,
        quality: 30,
        width: 100,
        height: 100,
        allowEdit : true,
        outputType: 1,
      }
      this.imagePicker.getPictures(options)
      .then(file => {
        //this.images = new Array(file.length);
        for (let i = 0; i < file.length; i++) {
        //this.images[i] = 'data:image/jpeg;base64,' + file[i]
        this.images.push('data:image/jpeg;base64,' +file[i]);
      }
    });
  }
私人摄像机:摄像机, 私有传输:文件传输, 私有文件:文件, 专用文件开启器:文件开启器, 私有加载Ctrl:LoadingController, 私人plt:平台, 专用图像选择器:图像选择器, 专用base64:base64, 私人消毒剂(消毒剂){ } 图像=[]; 公共项:数组=[]; 拍照{ this.imagePicker.hasReadPermission() 。然后(res=>{ 如果(res){ 这是openGallery(); }否则{ this.imagePicker.requestReadPermission() 。然后(res=>{ 如果(res=='ok'){ 这是openGallery(); } }) } }) .catch(错误=>console.log(错误)); } openGallery(){ 让选项={ 最大值:10, 对,, 质量:30, 宽度:100, 身高:100, 允许:是的, 输出类型:1, } 这个.imagePicker.getPictures(选项) 。然后(文件=>{ //this.images=新数组(file.length); for(设i=0;i
我一直在为我寻找一个和你一样的解决方案。。。你的代码是完美的。。。查看uqe通过添加“;”和减小图像大小和质量所做的小更改。。。 祝贺你,谢谢你帮助我!在你的手机上看到,如果你一退出应用程序就用这种方法杀死所有应用程序,因为这也可能是当你访问摄像头时应用程序停止的原因,因为它会死掉

let options = {
  maximumImagesCount: 10,
  width: 500,
  height: 500,
  quality: 100,
  outputType: 1
}

this.imagePicker.getPictures(options)
  .then(file => {
    this.images = new Array(file.length);
    for (let i = 0; i < file.length; i++) {
      this.images[i] = 'data:image/jpeg;base64,' + file[i]

    }
  })
constructor(public navCtrl: NavController,
    private camera: Camera,
    private transfer: FileTransfer,
    private file: File,
    private fileOpener: FileOpener,
    private loadingCtrl: LoadingController,
    private plt: Platform,
    private imagePicker: ImagePicker,
    private base64: Base64,
    private sanitizer: DomSanitizer) {
    }
    images=[];
    public items: Array<{ images: string;}> = [];
    takePhoto(){
      this.imagePicker.hasReadPermission()
      .then(res => {
        if (res) {
          this.openGallery();
        } else {
          this.imagePicker.requestReadPermission()
          .then(res => {
            if (res === 'ok') {
              this.openGallery();
            }
          })
        }
      })
      .catch(error => console.log(error));
    }
    openGallery () {
      let options = {
        maximumImagesCount: 10,
        correctOrientation: true,
        quality: 30,
        width: 100,
        height: 100,
        allowEdit : true,
        outputType: 1,
      }
      this.imagePicker.getPictures(options)
      .then(file => {
        //this.images = new Array(file.length);
        for (let i = 0; i < file.length; i++) {
        //this.images[i] = 'data:image/jpeg;base64,' + file[i]
        this.images.push('data:image/jpeg;base64,' +file[i]);
      }
    });
  }