objective-c - '+[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;
}
解决方案
推荐阅读
- ios - 使 iOS SwiftUI TextField 拒绝错误的数字输入
- mongodb - MongoDb 使用多个嵌套数组对文档进行排序
- laravel - Laravel 护照 / 允许客人使用 api 路由 / 绕过 Laravel api 中间件
- python-3.x - TypeError:“按钮”对象不可调用(pynput)
- java - Junit测试用例未使用maven运行
- go - UnhandledPromiseRejectionWarning:错误:nonce 生成函数失败或私钥在 Ganache 中无效
- python-3.x - 当我单击关闭然后再次单击运行时,我收到此错误“RuntimeError:线程只能启动一次”
- c# - 如何使用 Excel 互操作保存启用宏的工作簿 (xlsm)?
- c# - C#从数组中删除一个数字
- openedge - 使用参数的方法时出现运行时错误