[英]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.