.h文件
#import <UIKit/UIKit.h>
@interface UIStoryboard (MaxMethod)
+ (UIStoryboard *)loadWithName:(NSString *)name;
+ (UIViewController *)loadViewController:(Class)viewController;
@end
.m文件
#import "UIStoryboard+MaxMethod.h"
@implementation UIStoryboard (MaxMethod)
+ (UIStoryboard *)loadWithName:(NSString *)name {
return [UIStoryboard storyboardWithName:name bundle:[NSBundle mainBundle]];
}
+ (UIViewController *)loadViewController:(Class)viewController {
return [[UIStoryboard loadWithName:@"Main"] instantiateViewControllerWithIdentifier:NSStringFromClass(viewController)];
}
@end
网友评论