2015-03-02 66 views
0

我正在使用the following example from the offical website - 因此设置sourceType为CAMERA而不是PHOTOLIBRARY。ngCordova相机不打开相机,但相册

var options = { 
     quality: 50, 
     destinationType: Camera.DestinationType.DATA_URL, 
     sourceType: Camera.PictureSourceType.CAMERA, 
     allowEdit: true, 
     encodingType: Camera.EncodingType.JPEG, 
     targetWidth: 100, 
     targetHeight: 100, 
     popoverOptions: CameraPopoverOptions, 
     saveToPhotoAlbum: false 
    }; 

    $cordovaCamera.getPicture(options).then(function(imageData) { 
     var image = document.getElementById('myImage'); 
     image.src = "data:image/jpeg;base64," + imageData; 
    }, function(err) { 
     // error 
    }); 

,并使用PhoneGap的构建正在测试我的应用程序,从而结合以下插件在我的config.xml:

然而,当我发起上面的代码,然后在我的应用它打开我的电话相册 - 因此迫使我选择图像而不是拍摄照片。到底是怎么回事?

+0

你使用这些选项后建立自己的代码?可能你需要的东西像phonegap构建ios或phonegap构建android – 2015-08-17 16:35:32

回答

0

对于摄像头,你可以尝试这样一个

var options = { 
    quality: 50, 
    destinationType: Camera.DestinationType.FILE_URI, 
    sourceType: Camera.PictureSourceType.CAMERA, 
    allowEdit: true, 
    encodingType: Camera.EncodingType.JPEG, 
    targetWidth: 100, 
    targetHeight: 100, 
    popoverOptions: CameraPopoverOptions, 
    saveToPhotoAlbum: false 
}; 
$cordovaCamera.getPicture(options).then(function(imageURI) { 
    var image = document.getElementById('myImage'); 
    image.src = imageURI; 
}, function(err) { 
    // error 
}); 
+0

正是我所尝试的,但它仍然不访问我的相机,但我的电话相册... – JohnAndrews 2015-03-02 16:21:10

+0

我可以看到你的完整的源代码 – 2015-03-03 00:17:02