Created
December 22, 2013 16:45
-
-
Save kawanet/8085209 to your computer and use it in GitHub Desktop.
instantiateWithStoryboard 前提として、Storyboard IDとクラス名を揃えておく。以下のカテゴリを使うと、文字列指定でなくて、クラス指定任意の画面を取り出せるようになる。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface UIViewController (Util) | |
// Usage: | |
// FOOViewController *vc = [FOOViewController instantiateWithStoryboard:self.storyboard]; | |
// [self.navigationController pushViewController:vc animated:YES]; | |
+ (instancetype)instantiateWithStoryboard:(UIStoryboard *)storyboard; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "UIViewController+Util.h" | |
@implementation UIViewController (Util) | |
+ (instancetype)instantiateWithStoryboard:(UIStoryboard *)storyboard | |
{ | |
return [storyboard instantiateViewControllerWithIdentifier:NSStringFromClass(self)]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment