I want to my app run in landscape mode at first, I tried to add init in landscape to app plist, but I didn't get what I need, it will be in portrait mode all time, is it possible in landscape mode when simulator started?
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
It is ok, but not what I need, because I have run simulator at first and turn it left, then run my app.Leave your Simulator running in landscape-mode and then Build and Run your app.
Well, When I run it, simulator turned in landscape mode, this is what I need.You need a key in your applications main plist
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeRight</string>
Then you need to make sure to return to only allow the Right view (in this case) in all your views that load:
Code:- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); }
Well, When I run it, simulator turned in landscape mode, this is what I need.
But when I turned it left, I got a screen what I don't need, how can I solve it?
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation {
// Return YES for supported orientations
return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationPotrait));
}
My question might be not so clear, I need run my app on both mode, so I return YES for shouldAutorotateToInterfaceOrientation before I post here.What I linked will load it and "lock" it in landscape right mode. If you want it to automatically roll with the direction you have it facing, you have to return YES for each orientation you want to support:
Code:- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation { // Return YES for supported orientations return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationPotrait)); }
This would allow your app to run in portrait mode and in landscape-right mode. Of course you then have to do some view transformations in probably the viewDidAppear method otherwise your UI will look goofy as it rotates because none of the UI elements will be in the right place.
My question might be not so clear, I need run my app on both mode, so I return YES for shouldAutorotateToInterfaceOrientation before I post here.
My exact question is how to show simulator in landscape mode when start to run my app, then I can turn it left or right in portrait or landscape mode, may I make sense?
Yes, makes sense. And the only way I know how to force the Simulator to start with a certain orientation is to already have it running that way when you start your app, as I mentioned above.My exact question is how to show simulator in landscape mode when start to run my app, then I can turn it left or right in portrait or landscape mode, may I make sense?
Thanks, dejo, I try to improve my EnglishP.S. Quick English lesson, Mike. The proper phrasing would be "does that make sense?"
By the way, I want to know if it is a native English for "May I make sense?", when it can be used if it is?