[英]How to subclass Navigation Controller when using storyboards?
I'm using storyboards in interface builder using the Xcode menu 'Editor...Embed in...Navigation Controller'. 我在界面构建器中使用故事板使用Xcode菜单'Editor ... Embed in ... Navigation Controller'。
It seems that in iOS 6 you have to subclass the UINavigationController to allow all orientations, with 似乎在iOS 6中你必须将UINavigationController子类化为允许所有方向
- (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? 但是,如何将UINavigationController与故事板应用程序子类化,因为代码中没有对它的引用?
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
: 例如,将“Class”更改为
MyCustomNavigationController
,然后在项目中创建一个名为MyCustomNavigationController
的新类:
MyCustomNavigationController.h : MyCustomNavigationController.h :
#import <UIKit/UIKit.h>
@interface MyCustomNavigationController : UINavigationController
@end
MyCustomNavigationController.m : MyCustomNavigationController.m :
@implementation MyCustomNavigationController
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
... any other methods you want ...
@end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.