[英]How to subclass Navigation Controller when using storyboards?
我在界面构建器中使用故事板使用Xcode菜单'Editor ... Embed in ... Navigation Controller'。
似乎在iOS 6中你必须将UINavigationController子类化为允许所有方向
- (NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskAll );
}
但是,如何将UINavigationController与故事板应用程序子类化,因为代码中没有对它的引用?
您可以从故事板中选择导航控制器场景的导航控制器:
然后使用右侧的身份检查器来更改类:
例如,将“Class”更改为MyCustomNavigationController
,然后在项目中创建一个名为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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.