首页 > 解决方案 > '+[UIStoryboard storyboardWithName:bundle:]: 无法识别的选择器发送到类 0x10b546238'

问题描述

我有一个 UIStoryboard 扩展,它根据传入的类型/名称启动故事板。我正在使用 +[UIStoryboard storyboardWithName:bundle:] 创建故事板,但似乎 Objc 找不到它的选择器。

#define valueString(enum) [@[@"Main",@"Login"] objectAtIndex:enum]

@interface UIStoryboard (Utility)

typedef NS_ENUM(NSInteger, StoryboardType) {
    StoryboardTypeMain,
    StoryboardTypeLogin
};

- (instancetype) initWithType:(StoryboardType)type bundle:    (NSBundle*)bundle;
- (instancetype) initWithType:(StoryboardType)type;

@implementation

- (instancetype)initWithType:(StoryboardType)type bundle:(NSBundle *)bundle {
    self = [[self class] storyboardWithName:valueString(type) bundle:bundle];
    return self;

}


- (instancetype)initWithType:(StoryboardType)type {
    self = [[self class] storyboardWithName:valueString(type) bundle:nil];
    return self;
}

标签: objective-cstoryboarduistoryboardxcode-storyboardobjective-c-category

解决方案


推荐阅读