[AC-759] Ti.Media.openPhotoGallery is not working on iPad but fine on iPhone
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Needs more info |
Resolution Date | 2015-12-08T09:29:01.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Documentation |
Labels | ios |
Reporter | Silambarasan Raman |
Assignee | Marco Cota |
Created | 2015-03-31T10:38:06.000+0000 |
Updated | 2016-03-08T07:37:01.000+0000 |
Description
Titanium.Media.openPhotoGallery is not working for iPads.
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.
// ########## CODE STARTS HERE ########
var self = Titanium.UI.createWindow({
top : 0,
navBarHidden : true,
backgroundColor : "#FFF",
exitOnClose : false
});
var leftView = Titanium.UI.createLabel({
text : Click for Gallery",
width : 80,
height : 80,
left : 40,
top : 30,
zIndex : 2
});
self.add(leftView);
leftView.addEventListener('click', OpenPhoneGallery);
function OpenPhoneGallery(){
Ti.Media.openPhotoGallery({
success : function(ev) {
SharePageCallFunc(ev);
},
cancel : function(){
alert("Gallery is not opened");
},
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
});
}
function SharePageCallFunc(eve,hidecam){
var shareImageView = Ti.UI.createImageView({
width : Ti.UI.SIZE,
height: Ti.UI.SIZE,
image : eve.media,
left : 0,
top : 0,
bottom : 0,
autorotate:true,
top : 100
});
self.add(shareImageView);
}
self.open();
Hi Silambarasan, Please tried to use the latest SDK 3.5.1.GA, since we can't reproduce your problem.
Hi Shuo, I am already using Titanium SDK version 3.5.1.GA, But i am getting the issue with iPad with iOS version 7.1.1. Please check with that,
Shuo, any updates on this?
Hi Silambarasan, Can you please tell me if you can reproduce the problem in iOS 8.2. Thanks Regards, Shuo
Hi Shuo, I can't reproduce in iOS 8.2, But still getting an issue with iOS 7.1.1. Please check with that.
Hi Shuo, I assume an issue happening because of opening GALLERY from OVERLAY of Camera, Can you please try to open the camera on overlay and then Add one Label/button there, And call the Ti.Media.openPhotoGallery on that click event, And test with the iPad 7.1 and then let me know the status, Still can't find a solution for this issue, So i need your help here, I posted my code below for your reference // ########## CODE STARTS HERE ######## var self = Titanium.UI.createWindow( { top : 0, navBarHidden : true, backgroundColor : "#FFF", exitOnClose : false } ); // ############ Bottom VIEW WHICH SHOWS Controller Options ################### // var CustomControllerView = Titanium.UI.createView({ width : Ti.UI.FILL,height : 140,backgroundColor : "#666666",bottom : 0,layout : "horizontal" }); // ############ WHOLE PAGE WHICH SHOWS CAMERA ################### // var overlayView = Titanium.UI.createView(); overlayView.add(CustomControllerView); CustomControllerView.add(leftView); var leftView = Titanium.UI.createLabel( { text : Click for Gallery", width : 80, height : 80, left : 40, top : 30, zIndex : 2 } ); CustomControllerView.add(leftView); // ############ Function for Take Picture ################### // function takePictureViaCamera() { Ti.Media.takePicture(); } leftView.addEventListener('click', OpenPhoneGallery); function OpenPhoneGallery(){ Ti.Media.hideCamera(); // Hiding the camera which is showing in overlay Ti.Media.openPhotoGallery({ success : function(ev) { SharePageCallFunc(ev); } , cancel : function() { alert("Gallery is not opened"); } , 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 }); } // ######### CAMERA OPEN FUNC ########## // function CameraOpenFunc() { Titanium.Media.showCamera({ saveToPhotoGallery : false, success : function(ev) { Ti.API.info(JSON.stringify(ev)); SharePageCallFunc(ev, true); }, cancel : function() { }, error : function(error) { var a = Titanium.UI.createAlertDialog({ title : 'Camera' }); if (error.code == Titanium.Media.NO_CAMERA) { a.setMessage('Please run this test on device'); } else { a.setMessage('Unexpected error: ' + error.code); } a.show(); }, overlay : overlayView, transform : Ti.UI.create2DMatrix().scale(1), showControls : false, // don't show system controls mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO], autohide : false // tell the system not to auto-hide and we'll do it ourself, So we should handle // hide by Ti.Media.hideCamera(); }); } function SharePageCallFunc(eve,hidecam){ if (hidecam) { Ti.Media.hideCamera(); } var shareImageView = Ti.UI.createImageView( { width : Ti.UI.SIZE, height: Ti.UI.SIZE, image : eve.media, left : 0, top : 0, bottom : 0, autorotate:true, top : 100 } ); self.add(shareImageView); } self.addEventListener("open", CameraOpenFunc); self.open();
Hi Shuo, Thanks for Reopened.
hi Shuo and Motiur Any update?
hi Shuo and Motiur Any update? We are in urgent need of a fix
I have tested this issue and openPhotoGallery works as expected.
Testing Environment:
Titanium SDK: 3.5.1.GA Titanium CLI: 3.4.2 iOS Version: 7.1 iPad 2, OS X Version: 10.9.5, Appcelerator Studio: 3.4.2Hi Marco, Can you please test with the below code, and then let me know the result // ########## CODE STARTS HERE ######## var self = Titanium.UI.createWindow({ top : 0, navBarHidden : true, backgroundColor : "#FFF", exitOnClose : true }); // ############ Bottom VIEW WHICH SHOWS Controller Options ################### // var CustomControllerView = Titanium.UI.createView({ width : Ti.UI.FILL, height : 100, backgroundColor : "#F00", bottom : 0, layout : "horizontal" }); // ############ WHOLE PAGE WHICH SHOWS CAMERA ################### // var overlayView = Titanium.UI.createView(); overlayView.add(CustomControllerView); var leftView = Titanium.UI.createLabel({ text : "Click to Open Gallery", textAlign : Ti.UI.TEXT_ALIGNMENT_CENTER, width : 80, height : 80, left : 80, top : 0, zIndex : 2, backgroundColor:"#00F", borderColor:"#FFF", borderWidth:1, borderRadius:45 }); CustomControllerView.add(leftView); var rightView = Titanium.UI.createLabel({ text : "Click to Capture", textAlign : Ti.UI.TEXT_ALIGNMENT_CENTER, width : 80, height : 80, left : 120, top : 0, zIndex : 2, backgroundColor:"#00F", borderColor:"#FFF", borderWidth:1, borderRadius:50 }); CustomControllerView.add(rightView); rightView.addEventListener("click",takePictureViaCamera); // ############ Function for Take Picture ################### // function takePictureViaCamera() { Ti.Media.takePicture(); } leftView.addEventListener('click', OpenPhoneGallery); function OpenPhoneGallery() { Ti.Media.hideCamera(); // Hiding the camera which is showing in overlay Ti.Media.openPhotoGallery({ success : function(ev) { SharePageCallFunc(ev); }, cancel : function() { CameraOpenFunc(); }, 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 }); } // ######### CAMERA OPEN FUNC ########## // function CameraOpenFunc() { Titanium.Media.showCamera({ saveToPhotoGallery : true, success : function(ev) { Ti.API.info(JSON.stringify(ev)); SharePageCallFunc(ev, true); }, cancel : function() { }, error : function(error) { var a = Titanium.UI.createAlertDialog({ title : 'Camera' }); if (error.code == Titanium.Media.NO_CAMERA) { a.setMessage('Please run this test on device'); } else { a.setMessage('Unexpected error: ' + error.code); } a.show(); }, overlay : overlayView, transform : Ti.UI.create2DMatrix().scale(1), showControls : false, // don't show system controls mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO], autohide : false // tell the system not to auto-hide and we'll do it ourself, So we should handle // hide by Ti.Media.hideCamera(); }); } function SharePageCallFunc(eve, hidecam) { if (hidecam) { Ti.Media.hideCamera(); } var backView = Titanium.UI.createLabel({ text : "Back", textAlign : Ti.UI.TEXT_ALIGNMENT_CENTER, width : 60, height : 40, left : 20, top : 10, zIndex : 2, backgroundColor:"#0FF" }); self.add(backView); backView.addEventListener('click',CameraOpenFunc); var shareImageView = Ti.UI.createImageView({ width : Ti.UI.SIZE, //height : Ti.UI.SIZE, //width : 200, height : 200, image : eve.media, bottom : 0, autorotate : true, top : 60 }); self.add(shareImageView); alert("Image saved"); } self.addEventListener("open", CameraOpenFunc); self.open();
Hi Marco any news on this--we're trying to launch our app and would really appreciate if you can check it ASAP. Thanks in advance Sean
Hi Marco Wanted to follow-up. We are in URGENT need of a solution/fix and would really appreciate if you can check it ASAP. Thanks in advance Sean
[~supasnyder] i have checked on the latest code you have publish, the issue is being caused because of the view is not being directly added to the window, as a workaround you cold use a Ti.App.fireEvent to handle this:
Hi Marco Thanks for you comment, Will let you know the status once tested with iPad.(Tested with iPhone , its working fine)