【发布时间】:2016-08-24 14:43:24
【问题描述】:
我正在 Ionic Framework 中构建应用程序,但我在 Android 中的预览图像出现问题。它只是没有显示。我使用插件 Cordova Camera 从您的手机中拍摄和选择照片。在 iPhone 上,我确实看到了预览图像,所以一切正常。
有人知道为什么它不能在 Android 上运行吗?
此代码在 controllers.js 中:
$scope.addImage = function (type) {
if (type == 'take') {
$scope.cam = Camera.PictureSourceType.CAMERA;
} else if (type == 'select') {
$scope.cam = Camera.PictureSourceType.PHOTOLIBRARY;
}
var options = {
quality: 75,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: $scope.cam,
allowEdit: true,
correctOrientation: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 2000,
targetHeight: 2000,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function (imageData) {
$scope.imgURI = "data:image/jpeg;base64," + imageData;
$scope.image = imageData;
$scope.popover.hide();
}, function (err) {
console.log(JSON.stringify(err));
});
};
以及视图中的 HTML:
<div class="edit-image" ng-click="popover.show($event)">
<img ng-if="imgURI && imgURI === undefined" ng-src="{{imgURI }}" />
<img ng-if="!imgURI && imgURI === undefined" src="https://example.com/noimage.jpg" />
<img ng-show="imgURI !== undefined" ng-src="{{imgURI}}" class="take_picture" />
</div>
【问题讨论】:
标签: android cordova ionic-framework cordova-plugins