I'm using storyboards in interface builder using the Xcode menu 'Editor...Embed in...Navigation Controller'.
It seems that in iOS 6 you have to subclass the UINavigationController to allow all orientations, with
- (NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskAll );
}
But how do I subclass the UINavigationController with a storyboard app as there is no reference to it in the code?
Drag a Button from the Object Library and place it on top of the View Controller. Change the title to “Show First View Controller”. Next, drag another View Controller to the Storyboard and place it next to the root view controller.
Specifying the Initial View ControllerOpen Main. storyboard and select the Tab Bar Controller Scene. On the right, select the Attribute inspector. You'll find a checkbox named Is Initial View Controller.
To create a segue between view controllers in the same storyboard file, Control-click an appropriate element in the first view controller and drag to the target view controller. The starting point of a segue must be a view or object with a defined action, such as a control, bar button item, or gesture recognizer.
Go to the Storyboard. Select the View Controller and in The Editor menu select Embed in -> Navigation Controller. Next, drag a Bar Button from the Object Library to the left side of the Navigation Bar and name it "Left Item". Repeat this for the right side and name it "Right Item".
You can select the navigation controller scene's navigation controller from the storyboard:
And then use the identity inspector on the right to change the class:
For instance change the "Class" there to MyCustomNavigationController
and then just create a new class in your project called MyCustomNavigationController
:
MyCustomNavigationController.h:
#import <UIKit/UIKit.h>
@interface MyCustomNavigationController : UINavigationController
@end
MyCustomNavigationController.m:
@implementation MyCustomNavigationController
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
... any other methods you want ...
@end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With