Hi
I have just upgraded my xCode to the latest 4.5 with the latest ios6 SDK. I also have Titanium fully updated to the latest 2.1.3 GA.
My iPad app is now suffering from a problem with the openPhotoGallery method. My app runs in landscape mode only.
This worked perfectly fine beforehand but now i get no response after clicking the choosePhotoButton and it causes everything else in the app to freeze so no other buttons etc work
I have the following code setup:
// Create empty iPad popover var choosePhotoPopover; // Create dummy anchor point to fix popovers position on screen var choosePhotoPopoverAnchor = Ti.UI.createImageView({ width:1, height:1, top:51, left:513, opacity:0 }); // Create view to go inside iPad popover var choosePhotoPopoverView = Ti.UI.createView({ width:320,height:200, backgroundImage:'/images/view.png' }); // Create camera button var takePhotoButton = Titanium.UI.createButton({ width:160, height:200, top:0, left:0, backgroundImage:'/images/camera_btn.png' }); // Create choose photo button var choosePhotoButton = Titanium.UI.createButton({ width:160, height:200, top:0, right:0, backgroundImage:'/images/photo_btn.png' }); // Add buttons to popover view choosePhotoPopoverView.add(takePhotoButton); choosePhotoPopoverView.add(choosePhotoButton); // Add Photo Button Listener - on click create actual popover or show existing addPhotoButton.addEventListener('click', function(){ if(!choosePhotoPopover){ choosePhotoPopover = Ti.UI.iPad.createPopover({width:320,height:160, arrowDirection:Ti.UI.iPad.POPOVER_ARROW_DIRECTION_UP, navBarHidden:true}); choosePhotoPopover.add(choosePhotoPopoverView); choosePhotoPopover.show({view:choosePhotoPopoverAnchor}); } else { choosePhotoPopover.show({view:choosePhotoPopoverAnchor}); } });Then the actual opening of the photo gallery:
// attached click listener to the choose photo button thats within the iPad popover choosePhotoButton.addEventListener('click', function() { choosePhotoPopover.hide(); Ti.Media.openPhotoGallery({ success:function(event) { // start another function... }, cancel:function() {}, error:function(error) { alert('Camera Reel Error'); }, mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO] }); });Can anyone please help??
5 Answers
Just an update on this. Appcelerator have looked into this in jira:
It's a bug in iOS6 and Apple rather than appcelerator as explained here with full explanation seen on the ticket link
PhotoGallery(UIImagePickerController) is a portrait-only view controller and in iOS 6 Apple has started enforcing this rule. Short version being Landscape-only applications that invoke a portrait-only view controller (such as the Game Center sign-in screen or the UIImagePickerController) and are built using the iOS 6 SDK may crash/freeze up the UI. The crash log may look like "*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'" The interm solution, while Apple may fix this in the future release is to temporarily make container window in which the photogallery popover is to be attached to have a portrait orientation also included in them.
I also have the same problem..... found a JIRA Ticket for it..... and is marked resolved because they can't reproduce it......
Can anyone help with this? The example in the Jira ticket shows a solution but not by using an alert box - which 1. I cannot have in my app and 2. Seems like a very poor solution, I understand it may be a quick short term fix but m surprised its marked as resolved.
I am now in a position where my app fails to work as I have updated my test device to ios6 and developing using Xcode. 4.5 and seek 6 :(
i am also having a problem with this i posted my issue hear http://developer.appcelerator.com/question/144622/titaniummediaopenphotogallery-crashing-in-ios6 before i read this post it works with a alert but crashes without.
Whats the current status with this really need to get this sorted urgently
Thanks
Anyone having this problem this solution worked for me, wrap photo gallery around a empty window. Hope this doesn't cause any issues for older versions havent tested
var win = Ti.UI.createWindow({ orientationModes: [Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT] }); win.addEventListener("open", function() { win.orientationModes = [Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT, Titanium.UI.PORTRAIT]; Ti.Media.openPhotoGallery({ success: function(event) { // start another function... win.close(); }, cancel: function() { win.close(); }, error: function(error) { win.close(); alert('Camera Reel Error'); }, mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO] }); }); win.open();?
Your Answer
Think you can help? Login to answer this question!