【发布时间】:2014-05-07 18:23:01
【问题描述】:
我正在尝试在使用 Sencha Touch 2.3.1 和 Cordova 3.4.1-0.1.0 的应用程序中捕获图片。 阅读文档 (http://docs.sencha.com/touch/2.3.1/#!/api/Ext.device.Camera-method-capture) 看起来非常容易和简单,但我的体验非常奇怪。
首先我创建一个 Sencha Touch 应用并在其中初始化 Cordova
sencha app generate MyApp ./MyApp
cd ./MyApp
sencha cordova init
此时,当我尝试构建时,它可以在真实设备、android 模拟器甚至浏览器上正常工作。 然后,我更改了 Main.js 以添加捕获功能。
Ext.define('CameraTest.view.Main', {
extend: 'Ext.tab.Panel',
xtype: 'main',
requires: [
'Ext.TitleBar',
'Ext.device.*'
],
config: {
tabBarPosition: 'bottom',
items: [
{
title: 'Welcome',
iconCls: 'home',
styleHtmlContent: true,
scrollable: true,
items: {
docked: 'top',
xtype: 'titlebar',
title: 'Welcome to Sencha Touch 2'
},
html: [
"You've just generated a new Sencha Touch 2 project. What you're looking at right now is the ",
"contents of <a target='_blank' href=\"app/view/Main.js\">app/view/Main.js</a> - edit that file ",
"and refresh to change what's rendered here."
].join("")
},
{
title: 'Camera',
iconCls: 'action',
layout: {
type:"vbox",
pack:"center",
align:"center"
},
items: [
{
docked: 'top',
xtype: 'titlebar',
title: 'CameraTest'
},
{
xtype: 'panel',
html: '<img style="height: 200px; width: 200px;" src="http://placehold.it/200x200" />'
},
{
xtype: "button",
text: "Photo",
handler: function() {
function success(image_uri) {
var img = Ext.ComponentQuery.query("image")[0];
img.setSrc(image_uri);
}
function fail(message) {
Ext.Msg.alert("Failed: " + message);
}
Ext.device.Camera.capture({
sucess: success,
failure: fail,
quality: 50,
destination: 'data',
source: 'camera'
});
}
}
]
}
]
}
});
完成,应用停止加载。它卡在 appLoadingIndicator 中并且没有到达选项卡面板组件。
但是,如果我在浏览器中打开它,它就可以正常工作。 我什至不知道如何调试这个。
【问题讨论】:
标签: android mobile cordova sencha-touch android-camera