该应用程序正确打开,但当我尝试拍照(点击按钮)时没有任何反应.它应该显示相机拍摄的图像.
有人可以向我解释什么不起作用?该教程来自Ionic网站.
替代方案:有人有一个工作.git或phonegap代码?
解决方法 哦,所以我想出来了,这完全是关于正确设置config.xml!以下是如何使用Ionic和Phonegap Build构建示例相机应用程序的概述
1.安装NodeJs或转到c9.io(云环境)并启动NodeJs项目.如果需要,删除所有文件
2.安装Ionic并启动项目(此处:标签)
npm install -g cordova ionicionic start myApp tabs
2A. cd myApp
2B.可选,添加插件(如果在浏览器或模拟器上测试)
cordova plugin add org.apache.cordova.camera
3. cd www
4.通过Bower安装或在/ lib中解压缩ngCordova
bower install ngCordova
5.在index.HTML中添加ngCordova引用
在index.HTML中添加
<script src="lib/ngCordova/dist/ng-cordova.Js"></script>
之前
<script src="cordova.Js"></script>
6.在app.Js中添加’ngCordova’作为依赖项
angular.module('starter',['ionic','starter.controllers','starter.services','ngCordova'])
7.写下控制器
.controller("ExampleCtrl",function($scope,$cordovaCamera) { $scope.takePicture = function() { var options = { quality : 75,destinationType : Camera.DestinationType.DATA_URL,sourceType : Camera.PictureSourceType.CAMERA,allowEdit : true,enCodingType: Camera.EnCodingType.JPEG,targetWIDth: 300,targetHeight: 300,popoverOptions: CameraPopoverOptions,savetoPhotoAlbum: false }; $cordovaCamera.getPicture(options).then(function(imageData) { $scope.imgurI = "data:image/jpeg;base64," + imageData; },function(err) { // An error occured. Show a message to the user }); }});
8.在.HTML中使用控制器(不要忘记在app.Js中添加带有ExampleCtrl的状态tab.example)
<ion-vIEw vIEw-title="Example"> <ion-content> <img ng-show="imgurI !== undefined" ng-src="{{imgurI}}"> <img ng-show="imgurI === undefined" ng-src="http://placehold.it/300x300"> <button ng-click="takePicture()">Take Picture</button> </ion-content></ion-vIEw>
9.添加适当的config.xml.使用此模板:
https://github.com/phonegap/phonegap-start/blob/master/www/config.xml
总结以上是内存溢出为你收集整理的ios – Ionic Cordova相机无法正常工作全部内容,希望文章能够帮你解决ios – Ionic Cordova相机无法正常工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)