Question

Im developing an application using Titanium which is compatible for iPhone. I'm navigating between 4 views. 1st View (Portrait) ---> 2nd View (Landscape) --> 3rd View (Portrait) ---> 4th View (Portrait) SO I have 3 Portrait views in my application and I used Tiapp.xml and add

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

For 2nd View I used following code ;

var winCheckInLogin = Ti.UI.createWindow({
    backgroundColor : "black",
    orientationModes : [Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT],
    navBarHidden : true, // Hides the native title bar
});

winCheckInLogin.addEventListener("open", function() {
    Titanium.UI.orientation = Titanium.UI.LANDSCAPE_LEFT;
});

But for the loading time 2nd View appear on Portrait mode after I rotate my device it keep it as Landscape. I need to load it as Landscape mode and lock that screen as it is.

Please help me to solve this.

Thanks a lot

Était-ce utile?

La solution

Gayan, Using different orientation modes for a single app in iPhone is not recommended. Please read Orientation design principles

Apple's Developer documentation says: "People expect to use your app in different orientations, and it’s best when you can fulfill that expectation." In other words, don't look at handling orientation as a bother but an opportunity.

Apple further recommends that when choosing to lock or support orientation, you should consider following these principles:

On iPhone/iPod Touch – Don't mix orientation of windows within a single app; so, either lock orientation for the whole app, or react to orientation changes.

On iPhone – don't support the portrait-upside-down orientation because that could leave the user with their phone upside-down when receiving a phone call.

However, if you want to use different orientations, just add the following to your tiApp.xml under <orientations device="iphone"> tag

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

This will do the trick for you!!

http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Window-property-orientationModes

Autres conseils

In your tiapp.xml

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

For all Windows (and not views), be sure to add the property of that window as:

orientationModes: [Ti.UI.PORTRAIT]

for Portrait-only Windows,

and for lanscape-only:

orientationModes: [Ti.UI.LANDSCAPE_LEFT, Ti.UI.LANDSCAPE_RIGHT]

That should do the trick you're looking for.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top