程序退出打开图像来自离线应用程序中的$ cordovaCamera.getPicture函数

时间:2015-10-06 18:05:48

标签: camera ionic

任何人都可以在我的代码中告诉我我做错了什么,我在那里调用cordova.getPicture函数,第一次打开应用程序并在我的应用程序中启动相机然后单击然后app自动终止并出现错误

但是第二次当我打开应用程序然后它确定并显示在我的应用程序中时请帮助我

 $scope.browse_logo=function($event) {
         var uploadPopup = $ionicPopup.show({
        title: "Upload Ad picture",
        templateUrl: 'templates/explore1.html',
        buttons: [
            {
                text: '',
                type: 'button button-icon icon ion-ios-camera',
                onTap: function(e) {

                  document.addEventListener("deviceready", function () {

    var options = {
      quality: 75,
      destinationType: navigator.camera.DestinationType.DATA_URL,
      sourceType: navigator.camera.PictureSourceType.CAMERA,
      allowEdit: true,
      encodingType: 0,
      targetWidth: 320,
      targetHeight: 320,
    //  popoverOptions: CameraPopoverOptions,
      saveToPhotoAlbum: false,
      correctOrientation:true
    };

    $cordovaCamera.getPicture(options).then(function(imageData) {
  //    var image = document.getElementById('myImage');
      $scope.logoPhoto = imageData;
    }, function(err) {
      // error
    });

  }, false);
         }
            },
            {
                text: 'From gallery',
                type: 'button button-positive',
                onTap: function(e) {
                  //  e.preventDefault();
               //     alert('Getting gallery');
                     $cordovaCamera.getPicture({
                        quality: 75,

        targetWidth: 320,
        targetHeight: 320,
     allowEdit: true,
        encodingType: 0,
       destinationType: navigator.camera.DestinationType.DATA_URL,
                        sourceType: navigator.camera.PictureSourceType.SAVEDPHOTOALBUM
                    }).then(function(imageURI) {
                        //alert(imageURI);
                        $scope.logoPhoto = imageURI;


                    }, function(err) {
                        alert(err);
                    });
                }
            }
        ]
    });

 };

0 个答案:

没有答案