开发者

How to start Titanium iPad app in landscape mode?

I'm using Ti.UI.orientation = Ti.UI.LANDSCAPE_LEFT on app startup, which turns it to landscape, however there's a short rotat开发者_开发百科ion animation.

Is there a way to have it launch already in landscape to avoid this?


Try adding the following to your tiapp.xml:

<iphone>
        <orientations device="iphone">
            <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
        </orientations>
        <orientations device="ipad">
            <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
        </orientations>
</iphone>

Note that you'll still need to provide orientation preferences for the window, but I believe this will solve your issue on launch. You'll need to flush your /build/iphone/ (or similar) folder for the changes to apply.


The code you give in your example, Ti.UI.orientation = Ti.UI.LANDSCAPE_LEFT is deprecated per http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI-module.

Instead you set a window's orientationModes property after the window has been created. Here is what I have in an app I wrote where I'm restricting devices to portrait mode:

        var win = Ti.UI.createWindow({
        backgroundColor: st.ui.theme.backgroundColor,
        fullscreen: true,
        navBarHidden: true,
        exitOnClose: true
    });
    win.orientationModes = [Ti.UI.PORTRAIT];

Instead of win.orientationModes = [Ti.UI.PORTRAIT]; you should try win.orientationModes = [Ti.UI.LANDSCAPE_LEFT]; and see where it gets you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜