Appcelerator - Android开放图片库

时间:2012-05-11 13:20:39

标签: javascript android image titanium appcelerator

打开图库时,应用程序有时会崩溃,有时则不会。 它显示了一个java异常但没有有意义的消息。

有没有人有想法?我也使用了意图,但无法让它工作。

Thnxs!

这是我的代码示例:

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]
   });
}

2 个答案:

答案 0 :(得分:0)

HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache, no-store, must-revalidate");
HttpContext.Current.Response.AddHeader("Pragma", "no-cache");
HttpContext.Current.Response.AddHeader("Expires", "0");

答案 1 :(得分:0)

当我从项目切换时,上述评论从未解决过这个问题。