OC: UIStoryboard+MaxMethod

2018-11-06  本文已影响7人  一欧Yiou

.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
上一篇下一篇

猜你喜欢

热点阅读