I found the autorotation doesn't work after upgraded to iOS6 on iPhone4S with same source, what I can do?
(Deprecated in iOS 6.0. Override the supportedInterfaceOrientations and preferredInterfaceOrientationForPresentation methods instead.)
shouldAutorotateToInterfaceOrientation: is deprecated in iOS 6.0.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/doc/uid/TP40006926-CH3-SW23
That means that new applications should use the new way of doing things. However, if you implement that method, it's still called, and still does the right thing. (I just tested it to be sure.)
Except shouldAutorotateToInterfaceOrientation: is no longer called when running under iOS 6. (I just tested it to be sure.)
I add code as below, but it looks like same as before, no rotation.. what happened?shouldAutorotateToInterfaceOrientation: is deprecated in iOS 6.0.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/doc/uid/TP40006926-CH3-SW23
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
--opening mouth, inserting foot--
I tested it on the iPhone 6.0 simulator, and could swear it was calling shouldAutorotateToInterfaceOrientation. However, I just tried it on my newly upgraded iPad, and you're right, it's not calling shouldAutorotateToInterfaceOrientation under iOS 6. This is news to me.
I think that if your app is built for iOS < 6.0, it still calls shouldAutorotateToInterfaceOrientation for compatibility, but if you build with the base SDK >= 6.0, it doesn't call it any more.
The good news is that the new method, supportedInterfaceOrientations, is quite simple to implement.
I think our company is going to release our newest app with both methods in place. Under iOS 5, the system will call shouldAutorotateToInterfaceOrientation like always. Under iOS 6 (and later) it will call supportedInterfaceOrientations instead.
I first found out about this via the newer iPad simulator. Believe I was targeting iOS 5 on that as that app needs to run on iOS 5. So it does or can show up there too.
Tried it last night on the iPhone 6 Simulator and targeted iOS 5. Think I have the same problem with my personal app. Tried this app on the iPhone 5 today. Same issue.
A guy at work has my app from the app store and is running iOS 6 on a 4s. It rotates just fine.
This whole rotation thing is darn ugly. One guy I know referred to it as a bug. Boy, I wish! Would have been nice if Apple at least hi-lited it more. Most deprecations don't hit so quickly.
Anyway, I've got some work todo.![]()
I add code as below, but it looks like same as before, no rotation.. what happened?
Code:- (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; }
I still have to 'get it' too. The docs for supportedInterfaceOrientations say; "When the user changes the device orientation, the system calls this method on the root view controller or the topmost presented view controller that fills the window."
So it would appear any view controllers that do not match that narrow definition do not get the call.
More to learn.![]()
I add code as below, but it looks like same as before, no rotation.. what happened?
Code:- (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; }
[window setRootViewController: yourViewController];
Thank you very much, I got it!make sure you do this:
Code:[window setRootViewController: yourViewController];
on your first or master full screen view controller. You may hunt through your controllers, and see which one calls the above methods, or have to subclass a nav controller if that's your base controller.