我正在使用Titanium并在iOS上测试相机。我遇到了一个问题,在我通过相机页面之前,相机页面之后的代码正在运行。在下面的代码中,行'alert('Picture uploaded successfully.')
在相机屏幕打开之前执行..有任何想法吗?
var wincam;
wincam = Titanium.UI.createWindow();
if (Ti.Platform.osname === 'android') {
win.addEventListener('open', function(e) {
});
} else {
Titanium.Media.showCamera({
success:function(event)
{
var cropRect = event.cropRect;
var image = event.media;
Ti.API.debug('Our type was: '+event.mediaType);
if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
{
var imageView = Ti.UI.createImageView({
width:win.width,
height:win.height,
image:event.media
});
win.add(imageView);
}
else
{
alert("got the wrong type back ="+event.mediaType);
}
},
saveToPhotoGallery:false,
allowEditing:true,
mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO]
});
}
//open next page
var w3 = Titanium.UI.createWindow({
backgroundImage:'/images/5-survey.png'
});
w3.open();
alert('Picture uploaded successfully.');
答案 0 :(得分:0)
showCamera是一个异步事件,它不会停止执行上下文。如果您想要成功捕获图像的警报,请将警报置于成功事件中。
http://developer.appcelerator.com/question/144053/showcamera-issue-on-ios#answer-250088 - 1小时前由Anthony Decena回答