Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4137] Forced Orientation lost after Modal closed

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-06-24T13:23:58.000+0000
Affected Version/sRelease 1.7.0, Release 1.6.2, Release 1.8.0
Fix Version/sSprint 2011-25, Release 1.7.2
ComponentsiOS
Labelsn/a
ReporterAlan Leard
AssigneeBlain Hamon
Created2011-05-18T16:38:38.000+0000
Updated2011-12-03T17:55:56.000+0000

Description

If you set a locked orientation and then open a modal with other orientations allowed, then close that modal, the status bar resets to the original locked orientation, but the window doesn't. The same process with a regular window works as expected. If this fix can be rolled into 1.6.3 that would be great. Here is test code:

var win = Titanium.UI.createWindow();

win.orientationModes = [
	Titanium.UI.PORTRAIT,
	Titanium.UI.UPSIDE_PORTRAIT,
	Titanium.UI.LANDSCAPE_LEFT,
	Titanium.UI.LANDSCAPE_RIGHT,
	Titanium.UI.FACE_UP,
	Titanium.UI.FACE_DOWN
]; 

var landscape = Titanium.UI.createButton({
	title:'Allow Portrait Only',
	width:200,
	height:40,
	top:140
});

landscape.addEventListener('click', function()
{
	// set and enforce landscape for this window
	win.orientationModes = [
		Ti.UI.PORTRAIT
	]; 
    
    var modal = Ti.UI.createWindow({
        modal:true,
        backgroundColor:'blue',
        orientationModes:     [
          Ti.UI.LANDSCAPE_LEFT
        , Ti.UI.LANDSCAPE_RIGHT
        , Ti.UI.PORTRAIT
        , Ti.UI.UPSIDE_PORTRAIT
      ]

    });
    
    var label = Ti.UI.createLabel({
    text:'Now Rotate to landscape and close the window',
    color:'white',
    width:'auto'
    });
   
    var back = Ti.UI.createButton({
        title:'Close',
        style:Titanium.UI.iPhone.SystemButtonStyle.PLAIN
    });

    back.addEventListener('click', function() {
        modal.close();
        win.orientationModes = [
		Ti.UI.PORTRAIT
        ]; 
        Titanium.UI.orientation = Titanium.UI.PORTRAIT;

    });
    
    modal.add(label);
    modal.setLeftNavButton(back);

    modal.open();
});


win.add(landscape);
win.open();

Here is a screen shot of the results from a test in Kitchen Sink: http://screencast.com/t/k0lriaPtNuO

Attachments

FileDateSize
4137_2011-06-23-111048_Jeff-Haynies-iPad.crash2011-06-23T11:38:16.000+000018607

Comments

  1. Blain Hamon 2011-06-22

    Was in progress a while back
  2. Alan Vaghti 2011-06-23

    Included a crash log from pull request 147.
  3. Blain Hamon 2011-06-23

    After fixing the crasher, I have found one edge case: If the code is run as-is on a 3.2 iPad, it can make the modal in a bad state. HOWEVER, this ONLY affects 3.2 and not 4.0+ (Nor 3.1, oddly), and if win.orientationModes is only Ti.UI.PORTRAIT to begin with, it's all gravy. Since changing the orientation in the middle of the window hiding is a really strange situation, and won't be an issue in 1.8, this edge case will be a won't fix. But the rest of the bug is game on.
  4. Blain Hamon 2011-06-24

    Pull accepted, took a long time to figure out where it went and cherry-pick it into 1_7_X
  5. Eric Merriman 2011-07-06

    Fixed with iPhone 3GS (3.1.2), iPad 2 (4.3.3), iPod 3rd Gen (4.0.2), SDK 1.7.x r177ece80

JSON Source