how do i fix the device rotation in a titanium app across all mobile platforms? Any references to official doco would be super useful!
so i don't want to so much "disable rotation" as "only ever let the app run in a particular orientation" (which in my case is portrait mode)
cheers
The official web site is down at the moment, but you would want to look up 'orientation modes'. The following code locks my windows to only portrait mode in my app.
loginWin = Ti.UI.createWindow({
orientationModes: [Ti.UI.PORTRAIT]
});
// Required to fix Android still?
loginWin.orientationModes = [Ti.UI.PORTRAIT];
Full-ish answer - this will STILL allow an orientation change when the loading screen starts up. Titanium seems to be holding this one close to their chest, but here goes:
in the tiap.xml file, you need to make changes to the first indentation-level android element
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application>
<activity
android:configChanges="keyboardHidden|orientation"
android:name="org.appcelerator.titanium.TiActivity" android:screenOrientation="portrait"/>
<activity
android:configChanges="keyboardHidden|orientation"
android:name="org.appcelerator.titanium.TiTranslucentActivity"
android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent"/>
<activity
android:configChanges="keyboardHidden|orientation"
android:name="org.appcelerator.titanium.TiModalActivity"
android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent"/>
<activity
android:configChanges="keyboardHidden|orientation"
android:name="ti.modules.titanium.ui.TiTabActivity" android:screenOrientation="portrait"/>
<activity
android:name="ti.modules.titanium.ui.android.TiPreferencesActivity" android:screenOrientation="portrait"/>
</application>
</manifest>
</android>
the above code can be dropped in (remove the existing android element first, of course!) and should work.
The trick here is the use of
android:screenOrientation="portrait"
which sets the orientation to portrait. The other option is 'landscape', of course. I think if you leve this out the the default behaviour is to allow the orientation to switch around.
iOS is, of course, easier.
In the same tiapp.xml file you need
<ios>
<plist>
<dict>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
</dict>
</plist>
</ios>
this will replace whatever is in your current ios element, and is at the same level as the android element
ie
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
...
<ios>
...
</ios>
<android>
...
</android>
</ti:app>
I still don't know how to stop android (and possibly ios) from re-orienting the splash screen, if anybody knows how let me in on the secret!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With