2

I have an app that is on the app store supporting version ios5+. When I deployed this app to the store the base sdk was set to 5.0 and the deployment target was ios 5.0. It is currently running fine on ios 5 and 6 devices.

I have since upgraded my IDE to ios 6.0 - the base SDK is 6.0 and the deployment target is 5.0. however when I run this app in the 6.0 simulator or device I get shouldautorotate issues due that message being depreciated.

  1. Why if my deployment target is 5.0 is giving me these issues - I don't want to use ios 6.
  2. Why can I not set my base sdk to 5.0?

Update: This is how my controller looks currently. Unfortunately the preferredInterfaceOrientation is only getting called once not every time the orientation changes - this is no good for me as I manipulate the view in this method:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    [self layoutHomeViewButtons:toInterfaceOrientation];

    return YES;
}

- (BOOL)shouldAutorotate
{
    return YES;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}

- (NSUInteger)supportedInterfaceOrientations
{

    [self layoutHomeViewButtons:[self getInterfaceOrientation]];

    return UIInterfaceOrientationMaskAll;
}

Update 2: I have figured out how to get the supportInterfaceOrientations method to get called. In my MainWindow.xib I have a navigationcontroller set as the window's root view controller. As a subitem of this navigationcontroller I have my homeviewcontroller where the code above resides.

If I change this link so that the window's rootviewcontroller is the homeviewcontroller then the method gets called. However I need this navigationcontroller for my ui!

TheLearner
  • 19,387
  • 35
  • 95
  • 163
  • The iOS 6 simulator has a bug where rotation is not correctly responding to rotation. You should try it on a real device. And yes shouldautorotate is being depreciated and you should move to the new rotation way at some point. Keep de old rotation code in your app to keep support for iOS 5. – rckoenes Oct 12 '12 at 14:13
  • hey @rckoenes thanks for your response however shouldAutorotateToInterfaceOrientation is not getting called when I run on an ios6 device or simulator. when I switch to ios 5 simulator then it gets called. – TheLearner Oct 12 '12 at 14:16
  • Hmmm, it did in one of my projects. Did you set the supported interface orientation in the project settings.You might want to just add the new way of rotation to be future proof. – rckoenes Oct 12 '12 at 14:19
  • I have implemented the shouldautorotate method and it never gets called in the ios6 simulator or device - any ideas? – TheLearner Oct 12 '12 at 14:38

4 Answers4

4

What you are describing sounds a lot like what I faced when switching to iOS 6. It came down to the way that self.window is handled in your app delegate. If it applies in your case, basically, you want to change your code from

[self.window addSubview:navigationController.view];

to

[self.window setRootViewController:navigationController];

Once I did this, my rotation messages suddenly started firing as expected. Here is my blog post on this subject:

http://www.dosomethinghere.com/2012/09/24/the-app-delegates-uiwindow-is-finicky/

BP.
  • 10,033
  • 4
  • 34
  • 53
  • I am doing this in the mainwindow nib unfortunately – TheLearner Oct 12 '12 at 15:02
  • In the didFinishLaunchingWithOptions method of your app delegate, you should have one of the above lines of code in there that kicks off your application. (Unless there is a way to do it that is newish and that I don't know about, which is certainly possible.) – BP. Oct 12 '12 at 15:14
  • I have tried both ways. The way I am doing it is I set the rootViewController in the MainWindow.xib. The other way is the way you are doing it which I also tried now however it doesn't sort the issue at the top – TheLearner Oct 12 '12 at 15:15
0

To support the new rotation implement the following methods:

// Tell the system which orientations are supporter
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL) shouldAutorotate {
    return NO;
} 

// tell the system which rotation should be used when the viewcontroller is presented.
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeRight;
}
rckoenes
  • 69,092
  • 8
  • 134
  • 166
  • See update - I need to support all orientations and the preferredOrientation method only gets called once with ios6 device and simulator – TheLearner Oct 12 '12 at 14:56
0

The reason why these ios6 methods were not being called is because I was setting the rootviewcontroller of the window to be a navigationcontroller instead of my homeviewcontroller and that is why the methods were not called.

This is not useful for my solution so I am searching for answers but this does solve this question.

See my follow up question where I am trying to figure out how to have my navigationcontroller as the rootviewcontroller: iOS 6 bug: supportedInterfaceOrientations not called when nav controller used as window root

Community
  • 1
  • 1
TheLearner
  • 19,387
  • 35
  • 95
  • 163
0

I can see that this question is already answered. Anyway, we had the same problem when using Xcode 4.5. However, if we build the code with Xcode 4.4.x, autorotation is working perfectly even without the shouldAutorotate method. So, try building with Xcode 4.4.x.

yoninja
  • 1,952
  • 2
  • 31
  • 39