Problem
I think I found a bug in the OptionDialog. If one rotates an app to landscape, then opens a ModalWindow and there an OptionDialog. The OptionDialog is displayed centered and in portrait mode instead of landscape.
Test case
var win1 = Ti.UI.createWindow({orientationModes:[Titanium.UI.PORTRAIT,
Titanium.UI.UPSIDE_PORTRAIT,
Titanium.UI.LANDSCAPE_LEFT,
Titanium.UI.LANDSCAPE_RIGHT,]});
win1.open();
setTimeout(function() {
var win = Ti.UI.createWindow({title: 'MyApp'});
var button = Ti.UI.createButton({title: 'open'});
win.open({modal: true});
win.add(button);
button.addEventListener('click', function () {
var dialog = Ti.UI.createOptionDialog({title: 'test', options: ['1', '2', '3']});
dialog.show();
});
}, 5000);
I just set a timeout cause you need a few seconds to rotate the device. All orientations are allowed in
tiapp.xml
Steps to reproduce:
* Open app and rotate the iPhone or Simulator to landscape (cmd + left/right) while the window is black.
* After 5 seconds it'll open a Modal Window with white background and a button.
* Open the OptionDialog by pressing the 'open' Button.
Result:
The option dialog is centered and not correct displayed. See attached image.
Community Discussion
Q&A [iPhone: OptionDialog has wrong rotation if displayed within a Modal Window and landscape orientation](
http://developer.appcelerator.com/question/134792/iphone-optiondialog-has-wrong-rotation-if-displayed-within-a-modal-window-and-landscape-orientation)
adding orientationModes to the window correct the sample code
adding orientationModes to the window to correct the sample code
Pull pending https://github.com/appcelerator/titanium_mobile/pull/2104
Pull merged.
Closing as fixed. Tested and verified with: Titanium Studio, build: 2.1.0.201206251749 Titanium SDK: 2.1.0.v20120626104306 Device: iPhone 4S (5.0.1), iPhone simulator