我是Sencha的新手,並試圖建立一個簡單的流程,用戶需要選擇一張照片才能進入「第2步」。照片的選擇可以來自新的相機捕捉或來自現有照片。Sencha Touch 2 - 選擇一張照片
這裏是我的代碼,以捕捉照片:
Ext.device.Camera.capture({
success: function(image) {
Ext.create('myapp.view.PreviewImage', {
title: 'Test photo',
description: 'Testing a camera capture',
src: image,
fullscreen: true
});
},
quality: 75,
width: 200,
height: 200,
destination: 'data'
});
我在等我的iPhone在郵件到達,所以我可以測試照相機(因爲iOS的模擬器沒有硬件支持),所以上面的代碼可能會或可能不會工作。我的問題是,有什麼替代方案 - 我從Sencha Touch 2文檔的Ext.device.Camera
的示例中拿出了上面的代碼,我發現它們將它存儲在data
中。我注意到其他一些例子,data
將成爲app
的兄弟文件夾。
使用當前的Sencha Touch 2設備api瀏覽設備上的照片有可能嗎?我已經在Sencha論壇上讀過關於使用PhoneGap作爲本地設備包裝的一些帖子,但Sencha Touch 2有它自己的本地包裝器和設備API,所以我想我應該能夠在這裏包含整個應用程序。
據設在這裏的文檔(這似乎是不完整):http://docs.sencha.com/touch/2-0/#!/api/Ext.device.Camera
無論是煎茶打包和PhoneGap的實現將使用 機攝像頭功能採取或選擇照片。模擬器 實現將簡單地返回假圖像。
在文檔的Ext.device.Camera提到的兩種方法分別是capture()
和getInitialConfig()
可有人請點我的一個片段或我提供一個簡單的例子來瀏覽設備上的現有照片?
UPDATE - 每在回答中引用新文檔,這裏的source
屬性規格:
The source of where the image should be taken. Available options are:
album - prompts the user to choose an image from an album
camera - prompts the user to take a new photo
library - prompts the user to choose an image from the library
謝謝你的鏈接,現在我明白了 – AlienWebguy