dcloudio / dcloudio/mui

在 iOS 7 下不能在 Action Sheet 中调用摄像头和系统相册

Open
#57 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
13.5k
Forks
6.5k
PR merge metrics
No merged PRs in 30d

Description

代码如下:

``` javascript
mui.plusReady(function(){
function captureImage() {
var camera = plus.camera.getCamera();
var res = camera.supportedImageResolutions[0];
var fmt = camera.supportedImageFormats[0];
camera.captureImage(function(path){
alert("Capture image success: " + path);
}, function(error) {
alert("Capture image failed: " + error.message);
}, {
resolution: res,
format: fmt
});
}

function pickImageFromGallery() {
plus.gallery.pick(function(path){
alert("Success: " + path);
}, function ( err ) {
alert("Failed: " + err.message);
});
}

document.getElementById('camera').addEventListener('tap', function () {
// API plus.nativeUI.actionSheet( actionsheetStyle, actionsheetCallback );
// captureImage(); 放在外面的话就可以正常调用。
plus.nativeUI.actionSheet({
title: '请选择',
cancel: '取消',
buttons: [{title: '拍照'}, {title: '从相册中选择'}]
}, function (e) {

switch (e.index) {
// 取消
case 0:
break;

// 拍照
case 1:
console.log('111');
captureImage();
break;

// 从相册中选择
case 2:
console.log('222');
pickImageFromGallery();
break;

}

});
});
});
```

找了几台 iPhone 来测试,使用情况如下:

---

机型 iPhone 4s
系统 iOS 8
使用:调用摄像头和系统相册正常,但调用摄像头的时候有个很有趣的现象,每两次调用摄像头,一次可以正常使用,另一次就会显示黑屏,但拍出来的图片都是正常的。

---

机型 iPhone 5s
系统 iOS 7
使用:在 Action Sheet 中都不能调用摄像头和系统相册,第一次调用摄像头没反应,以后调用摄像头就会报 `Capture image failed: device busy`。
然后调用相册也是,第一次没反应,以后调用相册都会报 `Failed: undefined` 。
如果把代码放到 Action Sheet 外面的话,是可以正常调用的。

---

不知道有没解决方法?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.