我是 Sencha 新手,正在尝试构建一个简单的流程,用户需要选择一张照片才能继续“第 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 作为 native 设备包装器的帖子,但对于 Sencha Touch 2,它有自己的 native 包装器和设备 API,所以我想我应该能够在此处包含整个应用程序。
根据他们的文档(似乎不完整)位于:http://docs.sencha.com/touch/2-0/#!/api/Ext.device.Camera
Both the Sencha Packager and PhoneGap implementations will use the native camera functionality to take or select a photo. The Simulator implementation will simply return fake images.
Ext.device.Camera 文档中提到的唯一两个方法是 capture()
和 getInitialConfig()
有人可以给我指出一个 fragment 或为我提供一个简单的示例来浏览设备上的现有照片吗?
更新 - 根据答案中引用的新文档,以下是 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
最佳答案
您可以设置捕获方法的source
属性。
文档:http://docs.sencha.com/touch/2-0/#!/api/Ext.device.camera.Abstract-method-capture
Ext.device.Camera.capture({
source: 'library',
...
});
关于android - Sencha Touch 2 - 选择照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10525040/