目录
$camera
$camera是对相机、图库等操作的服务对象
$camera.open()
$camera.open()该方法用来打开系统相机,支持回调callback。通常获取相机拍摄的照片通过callback来实现。
语法
$camera.open(jsonArgs)
参数
- bindfield:存储照片的字段
 - callback:回调
 - compressionRatio:按比例压缩图片大小,值为0-1,例如:”compressionRatio” : 0.5
 
实例1
//open的时候指定了bindfield,callback中可以通过bindfield来获取照片$camera.open({"bindfield" : "image","callback" : function() {var img = $ctx.getString("image");$id("image0").set("src", img);}});
实例2
//open的时候指定了bindfield,callback中可以通过bindfield来获取照片$camera.open({"bindfield" : "image","compressionRatio" : 0.5,"callback" : function() {var img = $ctx.getString("image");$id("image0").set("src", img);}});
$camera.openPhotoAlbum()
$camera.openPhotoAlbum()该方法用来打开系统相册
语法
$camera.openPhotoAlbum(jsonArgs)
参数
- bindfield:存储照片的字段
 - callback:回调
 - compressionRatio:按比例压缩图片大小,值为0-1,例如:”compressionRatio” : 0.5
 - type:值为multiple时,表示支持选多张图片;为其它值或不传时为只能单选,此属性需要额外配置,参考实例2
 
实例1
$camera.openPhotoAlbum({"bindfield" : "image","callback" : function() {var img = $ctx.getString("image");$id("image0").set("src", img);}});
实例2
1、勾选插件
使用多选功能需要在appliction.xml中勾选 多图片选择(imageSelector) 插件
2、配置
需要在appliction.xml中手动编辑添加如下配置:
<view id="AlbumActivity" ref="com.yonyou.uap.um.control.imageselects.activity.AlbumActivity" type="android" include="true"><extend screenOrientation="portrait"></extend></view><view id="GalleryActivity" ref="com.yonyou.uap.um.control.imageselects.activity.GalleryActivity" type="android" include="true"><extend screenOrientation="portrait"></extend></view><view id="ImageFile" ref="com.yonyou.uap.um.control.imageselects.activity.ImageFile" type="android" include="true"><extend screenOrientation="portrait"></extend></view>
3、示例代码
$camera.openPhotoAlbum({"bindfield" : "image","type" : "multiple","callback" : function() {var img = $ctx.getString("image");$id("image0").set("src", img);}});
文档更新时间: 2018-03-26 12:05