I'm using a tabBarController with multiple UINavigationControllers in my iPhone app, and now I want to add support for rotation (on some view controllers, not all). I know I need to implement the supportedInterfaceOrientation method for my UIViewControllers.
When the device is rotated, the supportedInterfaceOrientation is called on the UINavigationController, but I need it be called on my viewControllers. What's the best way to do this?
I've seen some people create a category on UINavigationController that overrides supportedInterfaceOrientation to query the child viewControllers. But I know that Apple frowns upon using Categories to override methods. (I've implemented it like this, and it works fine, but I want to ensure the app continues to work with future version of iOS.)
What about using method swizzling?
Subclass UINavigationController?
Any suggestions appreciated. :)
If you use iOS 6+ I would suggest subclassing UINavigationController
and overriding supportedInterfaceOrientations
Something similar to:
- (NSUInteger)supportedInterfaceOrientations;
{
return [self.topViewController supportedInterfaceOrientations];
}