shouldAutorotateToInterfaceOrientation never called

376 views
Skip to first unread message

Paul Cantrell

unread,
Mar 2, 2009, 6:14:03 PM3/2/09
to iphon...@googlegroups.com
I'm try to make my app rotate, and I find that
shouldAutorotateToInterfaceOrientation is never called.

This has worked in the past with no trouble, but this time, I have a
rather complex view hierarchy:

UITabBarController
MyThingerController
MySubThingerController

I tried overriding shouldAutorotateToInterfaceOrientation on all three
controllers; it's not called anywhere.

Anybody have any theories on why it would never be called?

Cheers,

Paul

Neil Mix

unread,
Mar 2, 2009, 9:00:29 PM3/2/09
to iphon...@googlegroups.com
I remember encountering this once. I think the problem turned out to
be that my TabBarController's view wasn't a direct subview of the
window, but was enclosed in some other view instead. After placing
the view as a direct child of the window, it worked.

FWIW you can also subscribe to the orientation events directly,
something like this:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(deviceOrientationDidChange:)
name:@"UIDeviceOrientationDidChangeNotification"
object:nil];
--
My info:
Work: http://www.pandora.com/
Play: http://www.neilmix.com/

Paul Cantrell

unread,
Mar 3, 2009, 12:39:34 AM3/3/09
to iphon...@googlegroups.com
Neil —

THANK YOU. You're exactly right: the TabBarController's view must be a
direct subview of the window.

You have saved me from an irreversible descent into madness. I owe you
one.

P
_________________________________________________________________

"After hearing ten thousand explanations, a fool is no wiser.
But an intelligent person needs only two thousand five hundred."
—Mahabharata


Paul Cantrell

unread,
Mar 5, 2009, 11:42:59 PM3/5/09
to iphon...@googlegroups.com
An addendum to this, for any who are interested:

I ended up using the alternative NSNotificationCenter approach Neil
suggested below. This stopped the different controllers belonging to
the different tabs from fighting over whether the screen should
rotate. To do the animation, I applied an affine transform to the
landscape view.

This approach is worth considering if you're using a tab view
controller — or if you want fine-grained control over the transition
animation when the screen rotates.

Cheers, P
Reply all
Reply to author
Forward
0 new messages