Auto rotation or the views - ios

i am working with the application and want to stop the rotation when i move the device to landscape mode. Please help me out regarding this. Your help will be much appriciable.

just click on your project and click on General Tab and go to Deployment Info section
and unselect the Landscape Left and Landscape Right option.

If you don't want to support landscape orientation, in Xcode, select your project in the Navigator, then go to Deployment info and uncheck Landscape left and right.

In your "Deployment Info" go to "summary" there are "supprted device orientation" , you can set the device orientation.

Select the project and then go to the General Tab. There you can see the section Deployment Info with the option Device Orientation. Unselect all the orientations you don't need.

As above is one way to set portrait apps ....
but another way throughout coding like u set particular view portrait...
add this method in your view controller.
- (BOOL)shouldAutorotate;
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations;
{
return UIInterfaceOrientationMaskPortrait ;
}
u can also set the multiple value like ..
- (NSUInteger)supportedInterfaceOrientations;
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
it is useful for the different view set different orientation ..
Best of luck..

Go to Project-> TARGET-> General
In Deployment Info select iPhone/iPad.
Checkmark for desired Device Orientations.

Related

How do you change orientation in iOS

I have made an iOS project but don't know how to lock the orientation. How do i do that?
EDIT: i tried adding it programmatically but didn't work
You can go to the project settings and below you have 4 options remove or add checkmarks to change orientations.
If you go to your Xcode project in the navigator (should be the very top file) then go to the General tab for your main target, there will be 4 check boxes under the title Device Orientation. Select those based on the orientations that you would like to allow

How to disable changing of orientations in iOS 5.1.1 after rotation?

I would like to know how to disable Portrait and UpsideDown orientations in my app for iOS 5.1.1.
I want my app to use only LandScape orientation (interface was drawn in Interface Build in .xib file) and don't change it in case of rotation.
I need it especially for iOS 5.1.1
A similar question: how do you make an app ONLY support landscape?
This method was used in the answer above:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight)
return YES;
return NO;
}
You can set it in project settings. In xCode 5 you open the project navigator, click on your project, click on the general tab, and check the boxes you want.

How to make an iOS app Landscape ONLY

Seems like a simple thing to do right? Go to the Target's Summary tab and set "Supported Interface Orientations" to Landscape Right only. You would think that would mean the app would be landscape only. But no.
On a device running 5.1 for example, if you open the app and hold the phone in the correct landscape right position you will see the view rotated 90 degrees counterclockwise, as if it think it's supposed to be in portrait mode, unless you add something like this:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
But that only works for one view controller, and who knows if it works on all OS versions.
So how do you make an app landscape only? Do I have to add that code to every single view controller in the app? I do not need any rotation. All my views are designed in Landscape. I just want the app to open in Landscape Right mode and stay that way. And I want to support iOS 5 and up.
There are new methods introduced that you have to implement along with the old one they are as below
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
In Xcode you can navigate to your project settings -> summary -> iPhone/iPod deployment info. Here you can select the supported interface orientations. You can also edit the 'Supported interface orientations' array in your application's info.plist by adding the desired interface orientations application wide.
In the info.plist put the orientation to landscape

IOS Device Orientation Stuck at Portrait mode, no Landscape

I'm using Xcode 4.3.2 and an iPad simulator 5.1
I really need some help with this, my app is stuck at portrait mode.
When I rotate the simulator
I've tried looking under the project settings and have these checked:
Portrait, Upside Down, Landscape Left and Landscape Right.
I also these methods in the view controllers:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
can anyone please help?
Check your supporting orientations in the project's settings or on *.plist file. Also, if you are using UITabBarController or smth else, all of your controllers have to support all orientations!
use cmd+shift+f and type - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
make sure all of them return YES if you want all orientations supported and NO For unsupported orientations
Make sure you only have one controller showing. I've seen this problem when I have multiple views with different controllers showing at the same time.
Yeah I had the same problem and the other answers here didn't fix my situation. I found I had to check the "Resize View from NIB" box in all the relevant views.
See screenshot below (although shows a slightly older version of XCode).

how do you make an app ONLY support landscape?

how do you make an app ONLY support landscape? No portrait mode JUST landscape throughout the whole thing in xcode 3?
The accepted answer did not work for me. This did:
In the properties file for your app (YOURAPPNAME-Info.plist), located in the "supporting files" group, there is an array called "Supported interface orientations". Remove the orientations you don't want from the array, and your app will be locked into the remaining orientation.
My naive answer is to add this method in all of your root view controllers:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight)
return YES;
return NO;
}
This is what I do in my game. Of course, my game only has one view controller.
Also, I found it helpful to set "Initial interface orientation" in my app's info.plist to Landscape.
You can change the Supported interface orientations in your info.plist file, as shown below:
Orientations are now easily set using the target's summary tab.
We can change the orientation by simply selecting the required orientations as well. Select the device from "devices" and change the orientation

Resources