Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Limiting orientation modes on iOS

...

Specify the orientation modes the application needs to support with the UISupportedInterfaceOrientations key in the iOS plist section of the project's tiapp.xml file.

...

By default, Titanium sets iPhone applications to support upright portrait only and iPad application to support all orientation modes.

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
    <ios>
   <orientation>Ti.UI.PORTRAIT</orientation>     <plist>
            <dict>
                <key>UISupportedInterfaceOrientations~iphone</key>
    </orientations>            <array>
                    <string>UIInterfaceOrientationPortrait</string>
                </array>
    <orientations device="ipad">         <orientation>Ti.UI.PORTRAIT</orientation>  <key>UISupportedInterfaceOrientations~ipad</key>
        <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>        <array>
                    <string>UIInterfaceOrientationPortrait</string>
        <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>            <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>            <string>UIInterfaceOrientationLandscapeLeft</string>
    </orientations>
</iphone>
                <string>UIInterfaceOrientationLandscapeRight</string>
                </array>
            </dict>
        </plist>
    </ios>
</ti:app>

Limiting orientation modes on Android

...

The preceding techniques control the orientation modes supported by your entire app, including all its windows. But what if you want window A to be in portrait while window B is in landscape? You can limit the orientation modes supported by a specific window by setting the window's orientationModes property. This property accepts an array of Ti.UI constants that specify the window's permitted orientations. Remember, you must have enabled the various orientations in the tiapp.xml before setting a window to that orientation.

Note
titleiOS Platform Notes

Using the Window's orientationModes property to force the orientation of non-modal windows is considered a bad practice and will not be supported, including forcing the orientation of windows inside a NavigationWindow or TabGroup.

Modal windows should not support orientation modes that the window they are opened over do not support. Doing otherwise may cause bad visual/redraw behavior after the modal is dismissed, due to how iOS manages modal transitions. Beginning with 3.1.3, if the orientationModes property of a modal window is undefined, then the orientations supported by this window would be the orientation modes specified in the tiapp.xml.

Code Block
langjavascript
var win = Ti.UI.createWindow({
	/* on Android, it needs to be a "heavyweight" window */
	fullscreen: false,
	/* This works on iOS */
	orientationModes: [
		Ti.UI.PORTRAIT,
		Ti.UI.UPSIDE_PORTRAIT
	]
});
// but for Android using Titanium prior to 2.1 you have to set it after creation
win.orientationModes = [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT]

...