Quantcast
Viewing all articles
Browse latest Browse all 8068

Opening photo gallery in iPad

Titanium SDK version 3.1.2.GA iOS SDK: 6.0 iOS iPad Simulator: 6.0 Alloy: 1.0

I'm using the same code to open a photo gallery from kitchen sink but it doesn't work on iPad. When I click the button that's supposed to open the photo gallery, the screen freezes up and nothing can be clicked. Is this some sort of bug? Is a popover required to open the photo gallery on an iPad?

var popoverView, arrowDirection, imageView;
 
function openGallery() {
    Titanium.Media.openPhotoGallery({
 
        success:function(event)
        {
            var cropRect = event.cropRect;
            var image = event.media;
 
            // set image view
            Ti.API.debug('Our type was: '+event.mediaType);
            if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
            {
                //this would change the image to a picture
                imageView.image = image;
            }
            else
            {
                // is this necessary?
            }
 
            Titanium.API.info('PHOTO GALLERY SUCCESS cropRect.x ' + cropRect.x + ' cropRect.y ' + cropRect.y  + ' cropRect.height ' + cropRect.height + ' cropRect.width ' + cropRect.width);
 
        },
        cancel:function()
        {
 
        },
        error:function(error)
        {
        },
        allowEditing:true,
        popoverView:popoverView,
        arrowDirection:arrowDirection,
        mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO]
    });
}
 
function photo_gallery() {
    var win = Titanium.UI.createWindow();
    imageView = Titanium.UI.createImageView({
        height:200,
        width:200,
        top:20,
        left:10,
        backgroundColor:'#999'
    });
    win.add(imageView);
 
    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;
    }
 
    if (Ti.Platform.osname === 'android') {
        win.addEventListener('open', function(e) {
            openGallery();  
        }); 
    } else {
        openGallery();
    }
 
    return win;
};
I've also tried this code, but it doesn't work either, the screen just freezes up and no buttons can be clicked.
function openGallery() {
 
    Titanium.Media.openPhotoGallery({
 
    success : function(event) {
        newImg = event.media;
    },
    cancel : function() {
    },
    error : function(error) {
    }
});
}
Appreciate any suggestions, feedback, or code samples.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>