Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13240] iOS: Media - Titanium.Media.openPhotoGallery is not working for iPads

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionInvalid
Resolution Date2013-04-01T23:16:45.000+0000
Affected Version/sRelease 3.1.0
Fix Version/s2013 Sprint 07 API, 2013 Sprint 07
ComponentsiOS
Labelsqe-3.1.0
ReporterAnshu Mittal
AssigneeSabil Rahim
Created2013-03-28T11:39:44.000+0000
Updated2015-03-31T10:38:49.000+0000

Description

Titanium.Media.openPhotoGallery is not working for iPads. This is not regression since the issue occurs on 3.0.2 GA as well Steps to reproduce: 1. Create an app using the code below. 2. Launch the test app. Actual: No photo gallery is invoked on iPads whereas photo gallery is successfully invoked on iPhones. Expected: Photo gallery should be invoked on iPads as well.
 


var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'white'
});

 
var imageView = Titanium.UI.createImageView({
    height:200,
    width:200,
    top:20,
    left:10,
    backgroundColor:'#999'
});
 
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;
}
 
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)
        {
            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()
    {
        alert('cancelled fired');
    },
    error:function(error)
    {
    },
    allowEditing:true,
    popoverView:popoverView,
    arrowDirection:arrowDirection,
    mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO]
    
});

win1.add(imageView);

win1.open();
	

Comments

  1. Sabil Rahim 2013-04-01

    Test case is invalid. use this code
       var win = Titanium.UI.createWindow({  
           title:'Tab 1',
           backgroundColor:'white'
       });
       var imageView = Titanium.UI.createImageView({
       	height:200,
       	width:200,
       	top:20,
       	left:10,
       	backgroundColor:'#999'
       });
       
       win.add(imageView);
       
       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;
       }
       
       imageView.addEventListener('click', function(){
       
       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)
       		{
       			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]
       });
       
       
       
       
       });
       
       win.open();
       
    Now click on the imageView. popup should appear. Marking ticket as invalid.
  2. Anshu Mittal 2013-04-10

    Tested with: SDK: 3.1.0.v20130409124549 Studio:3.1.0.201304011603 Device: iPad2(v 5.1) OS: OSX 10.7.5 Changed test case works well for iPads as well.
  3. Silambarasan Raman 2015-03-31

    function OpenPhoneGallery(){ this.animate(VARS.a); Ti.Media.openPhotoGallery({ success : function(ev) { SharePageCallFunc(ev); }, cancel : function(){ alert("Gallery closed"); }, error : function(err){ var a = Titanium.UI.createAlertDialog({ title : 'Gallery' }); a.setMessage('Unexpected error: ' + err.code); a.show(); }, showControls : false, mediaTypes : Ti.Media.MEDIA_TYPE_PHOTO, autohide : true }); }
  4. Silambarasan Raman 2015-03-31

    function OpenPhoneGallery(){ this.animate(VARS.a); Ti.Media.openPhotoGallery({ success : function(ev) { SharePageCallFunc(ev); }, cancel : function(){ alert("Gallery closed"); }, error : function(err){ var a = Titanium.UI.createAlertDialog({ title : 'Gallery' }); a.setMessage('Unexpected error: ' + err.code); a.show(); }, showControls : false, mediaTypes : Ti.Media.MEDIA_TYPE_PHOTO, autohide : true }); }
  5. Silambarasan Raman 2015-03-31

JSON Source