打开图片库时,有时应用程序会崩溃,有时则不会。它显示了一个 java 异常,但没有任何有意义的消息。
有人有想法吗?我也使用了意图,但无法让它发挥作用。
谢谢!
这是我的代码示例:
Here a sample of my code:
function openGallery() {
var popoverView;
var arrowDirection;
if(Titanium.Platform.osname == 'ipad') {
// photogallery displays in a popover on the ipad and we
// want to make it relative to our image with a left arrow
arrowDirection = Ti.UI.iPad.POPOVER_ARROW_DIRECTION_LEFT;
popoverView = imageView;
}
var image = undefined;
Titanium.Media.openPhotoGallery({
success : function(event) {
var cropRect = event.cropRect;
image = event.media;
// set image view
Ti.API.debug('Our type was: ' + event.mediaType);
if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
addAttachment(image);
} else {
// is this necessary?
}
},
cancel : function() {
},
error : function(error) {
},
allowEditing : true,
saveToPhotoGallery : true,
popoverView : popoverView,
arrowDirection : arrowDirection,
mediaTypes : [Ti.Media.MEDIA_TYPE_VIDEO, Ti.Media.MEDIA_TYPE_PHOTO]
});
}