Forcing rotation to landscape - iphone

I would like my app's rotation to be fixed as landscape...
I've done some research, but most posts are about detecting change,
and I couldn't find any about forcing one.
Could anyone help me?

Try this
In plist change the Supported interface orientations to Lansdscape
OR
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); // home button on right
}
All the best

You can change the info.plist of your project so that you app always shows Landscape initially.And then you can make your view controller's to support only landscape orientation.
hope this also helps
Only support for landscape Interface orientation
Launching application in landscape orientation for IPad

Related

Image orientation distorts to the wrong orientation on startup (iOS)

I have an app, haven't modified it since 6 months ago, anyway I decided to open it up in the simulator. But the first viewcontroller which shows after the splash screen is scrunched up and is showing through the wrong orientation. It's showing in portrait when it should be showing in landscape.
This is the code for it:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
However,
When I tap to go to another view, then go back to the main viewcontroller, the problem fixes itself and the orientation is correct.
So it only happens on the initial launch after the splash screen is shown.
Please join the links together to view the screenshots as i cannot post images as i haven't got 10 reps yet.
This will make sure the app to open in landscape mode .
In the AppDelegate you may be using this
[self.window addSubView:viewControllerObj]
The problem was with the above line. Orientation will work properly with the above line in iOS 5 but in iOS 6, for orientation to work properly, change the above line with
[self.window setRootViewController:viewControllerObj]
Then the app rotates when orientation changes
Open your plist file ->addRow-> add "Initial interface orientation" and give value Landscape (left home button).
Hope this will help you.

xcode 4.2.1 - rotation support issue

I have designed an app to support ios 4.3 and from "Supported Device Orientations" I removed everything and only portrait is active.
The problem is that when I simulate the app in my phone it supports all the orientations and my app looks missed up with the landscape orientations.
how can I force it not to support landscape orientations?
In your view controller call
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
to force it not to rotate in landscape mode. You will also need to make sure all of your parent views have autoresizesSubviews = YES.

How to change already developed app into both orientations Landscape and portrait?

I developed app(navigation + tabbar) in portrait mode.
But now I want that if user change its orientation to landscape or
portrait then all should be rotate in that orientation.
You need to set each view's control autoresizingmask. You can do it through xib as well as code as per your need and add below method in all viewControllers and it should work.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
return YES;
}
Hope this help.
And have a look into your ".plist", you can define "Supported interface orientations" (UISupportedInterfaceOrientations) here.

ipad 3.2.2 loading in landscape

I changed the properties in info.plist to support orientation in landscape thereby the app opens in landscape mode as well. The problem which i face is like when the app loads in landscape mode the view is properly aligned. There is a view on the right side of the split view is not aligned properly. But when i load that in the portrait mode and then into landscape there are no issue. Can you tell me if there are additional properties or some work around for this issue.
as you are using splitview controller you should not worry about orientation.
just see in your view .nib file there is one authosizing feature set that properly u will remove this problem.
This link may help you if you dont know about autosizing.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
add this code...hope it will work...

root UIViewController orientation landscape, touches weird in subviews

I'm making an application which will be landscape only. Therefore, my root UIViewController is set to be landscape (all xib files I have are landscape orientation).
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
When I try to touch a button in one of the subviews, it does not receive a touch. If I remove the override shown above, the buttons get the touches, but the subview is shown in portrait orientation.
How should I work around this problem?
Thanks & Best Regards,
David
Aside from that, you have to set the supported orientations in your info.plist file.
Its under "Supported interface orientations", with key "UISupportedInterfaceOrientations". Remove the portrait orientations in the list.