我已经尝试了2天才能使用此代码显示我的故事板:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *LoginViewController = [storyboard instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = LoginViewController;
[self.window makeKeyAndVisible];
return YES;
}
但是,我不断收到此错误并在我的主要内容中出现一个sigbart:'NSInvalidArgumentException',原因:'无法在捆绑NSBundle(已加载)中找到名为'MainStoryboard'的故事板'
谷歌似乎没有关于这些错误的消息?有没有人知道如何解决它?
更新:当我将其更改为:
时- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
UIViewController *LoginViewController = [storyboard instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = LoginViewController;
[self.window makeKeyAndVisible];
return YES;
}
它给了我错误: [3208:c07]如果想要使用主故事板文件,app委托必须实现window属性。
{AppDelegate setWindow:]:无法识别的选择器发送到实例0x962bf30
[3208:c07] * 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [AppDelegate setWindow:]:无法识别的选择器发送到实例0x962bf30'
答案 0 :(得分:4)
终于找到了!!!!!!事实证明我忘记将这行代码放在app delegate头文件中:
@property (strong, nonatomic) UIWindow *window;