Ios7 UIImagePickerController:忽略拍照请求;摄像机正在改变模式
这个错误在ios7上抛出,我在Tianium中构建了一个小型示例照相机应用程序,代码如下: index.jsIos7 UIImagePickerController:忽略拍照请求;摄像机正在改变模式,ios7,titanium,ios-camera,Ios7,Titanium,Ios Camera,这个错误在ios7上抛出,我在Tianium中构建了一个小型示例照相机应用程序,代码如下: index.js var overlay = Ti.UI.createView({ width: Ti.UI.FILL, height: Ti.UI.FILL, backgroundColor: 'transparent' }); var takePhotoBtn = Ti.UI.createButton({ width: '200dp', height: '60
var overlay = Ti.UI.createView({
width: Ti.UI.FILL,
height: Ti.UI.FILL,
backgroundColor: 'transparent'
});
var takePhotoBtn = Ti.UI.createButton({
width: '200dp',
height: '60dp',
bottom: '100dp',
backgroundColor: '#FFF'
});
var btnLbl = Ti.UI.createLabel({
text: 'Take Photo'
});
takePhotoBtn.addEventListener('click', function(e){
Ti.Media.takePicture()
});
takePhotoBtn.add(btnLbl);
overlay.add(takePhotoBtn);
$.back.addEventListener('click', showCamera);
$.index.open();
function showCamera(){
Ti.Media.showCamera({
success: function(event){
var imageData = event.media;
$.resultImg.setImage(imageData);
Ti.Media.hideCamera();
},
error: function(error){
Ti.API.info('Error: ' + JSON.stringify(error));
},
overlay : overlay,
saveToPhotoGallery: false,
allowEditing: false,
mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO],
showControls : false,
autohide : false,
//make the picture inside the camera smaller so that we
//can than place an overlay around it
transform: Ti.UI.create2DMatrix({
scale : 0.5
})
});
Ti.Media.switchCamera(Ti.Media.CAMERA_FRONT);
}
在index.xml中
<Alloy>
<Window class="container">
<Button id="back" title="Start camera"/>
<ImageView id="resultImg"/>
</Window>
</Alloy>
它不是每次拍照都会发生,但可能每10次。请帮忙 当您连续拍摄多张照片时,iPhone无法处理之前的照片。使用Objective-C时,可以使用以下代码添加observer:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(cameraIsReady:)
name:AVCaptureSessionDidStartRunningNotification object:nil];
但是,此API未在Tianium中实现,因此现在要解决此问题,您必须捕获此错误,等待几秒钟显示用户快速信息,然后重试。我已在Tianium中解决了此问题,方法是在实例化相机后,在前后转动相机之前,添加第二个超时,再过500毫秒,拍摄活动才能完成。