I've looked everywhere, Yet I cant find a solution for this annoying rotation issue in iOS 6.
for some reason, I cant get the rotation methods in iOS 6 to work. they are not even called.
for example:
if I want to keep a view in portrait mode in iOS 5, I use:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
I learned that the new method in iOS 6 should be:
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
I've also try to add:
-(BOOL)shouldAutorotate
{
return NO;
}
but it dosent work at all.
please help!
If you have all that it should be as simple as setting the supported orientations in the Info.plist as well as in your controllers. You can do this through the Summary tab on your project target.
Related
I developed an app with Xcode 4.4 and iOS 5.1. I updated Xcode to 4.6.2 and iOS is 6.1, but I have selected the target as iOS 5.1 (even though I am using Xcode 4.6.2). My app supports all orientations.
My question is: I want to restrict some views in landscape mode, it is working fine in the simulator but when I am running the app in iPhone 5 device, my methods are not working, kindly help me?
In your view controller(s) where you want to restrict your orientation I would do the following:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return interfaceOrientation == UIInterfaceOrientationLandscape;
}
Regarding your iPhone 5 the shouldAutorotateToInterfaceOrientation was deprecated with iOS6 so you're going to have to do an OS check and implement/override the supportedInterfaceOrientations and preferredInterfaceOrientationForPresentation methods instead.
I use this in my app and it works perfect!
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
When you want a view only for portrait use this:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
I have a app which i want to display in portrait mode. But I only want to show one view in both modes.
I have do this for iOS5 . But in iOS6,i can't able to do this.
I also tried many codes to solved it.
How can I solve this problem?
apple has changed orientation in ios 6 .
in short use following steps:
1) set supported orientations in Targets->Summary...
2)In iOS6.0 shouldAutorotateToInterfaceOrientation Method is
deprecated.So,instead of this method we have to use shouldAutorotate
Method.
- (BOOL)shouldAutorotate
{
return NO;
}
3) in method supportedInterfaceOrientations we have to set which
orientations we want like UIInterfaceOrientationMaskAll if we want
all orientations
- (NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown );
}
I was build an app in ios 4.1 but now i am using ios 6 to build it but there are problems in pushviewcontroller and orientation methods. So can any one tell me what are the changes have brought in ios 6?
I think that best solution is to stick to official apple documentation. So according to that I use following methods and everything is working very well on iOS 5 and 6. In all of your ViewControllers override following methods.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
Methods for iOS 6, first method returns supported orientation mask (as their name indicate), you can change it into Landscape or what suites you best.
-(NSInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait; //UIInterfaceOrientationMaskPortrait or LandscapeLeft ...
}
second one thats tells your VC which is preferred interface orientation when VC is going to be displayed.
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait; //tells your VC in which orientation it should be presented, if you set Porttrait it would be in Portrait or otherwise ...
}
This solution is working
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Autorotate in iOS 6 has strange behaviour
I have issue with IOS 6, the display show up as portrait and not as landscape.
I am using both real and simulator device, if I build the game on 5.1 simulator the view is properly presented if I am using simulator version 6 or the real device with version 6 the view is get portrait view.
Here is my code.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if( interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight )
return YES;
Any idea how to solve such issue?
Thanks
ER
ShouldAutoRotation does not work anymore for iOS 6. Use supportedInterfaceOrientations instead.
You can get more information here: http://dhilipsiva.blogspot.com/2012/07/ios-6-ui-interface-orientation.html
Hope this helps.
The method shouldAutorotateToInterfaceOrientation has been deprecated for iOS 6. It has been replaced with the following:
- (BOOL)shouldAutoRotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
Also, there's a VERY important detail to make this work. In your AppDelegate, make sure you change the following:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window setRootViewController:<your main view controller here>];
}
If you're using [self.window addSubview:self.mainViewController.view], it won't work.
If you want to support iOS 5 as well as iOS 6, leave shouldAutorotateToInterfaceOrientation in your code; just know that it won't be called on iOS6 devices.
The example #Simon gave should be able to coexist peacefully with your original code, with either operating system calling its applicable method. I was able to implement something similar in my app, but I used the project settings to set up autorotation for iOS 6 and just left my shouldAutorotateToInterfaceOrientation alone to make the app compatible with iOS 5 too.
I'm trying to get my app updated to work with the new iPhone 5, and some of my views are dropping the keyboard down from the top of the view instead of the bottom. Here's an image to better illustrate:
This worked before iOS 6.0, so I'm guessing it must be something in the new API that is causing this bug to shine. I am using the following code to support orientations in the UIVeiwController:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
Has anyone else seen a similar problem? Thanks!
I have tried to replicate your issue but it works good for me on iOS6. My suggestion might be not very helpful but review that delegate, the synthesize and all the features match.
I found the answer at this question. My problem was fixed by changing one line of code where I was setting up my root UI view controller.
Changing this line:
[window addSubview:viewController.view];
to this:
[window setRootViewController:viewController];
Andrew, I also find that the method shouldAutoROtateToInterfaceOrientation was deprecated in iOS 6.
Anyways, I saw you solved your issue.