什么是正确的方式来继续这个布尔?

我有我的AppDelegate.m这个布尔:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; UIViewController *viewController = // determine the initial view controller here and instantiate it with [storyboard instantiateViewControllerWithIdentifier:<storyboard id>]; self.window.rootViewController = viewController; [self.window makeKeyAndVisible]; return YES; } 

我在*故事板上得到一个错误,但我主要试图做的是初始化应用程序在一个不同的视图控制器比主要的。 我有所有的视图控制器与ID(如我想要启动的名为“家”)。 如果说我的ViewController ID是在家,我该如何正确地写这个布尔?

我的main.m:

 #import <UIKit/UIKit.h> #import "AppDelegate.h" int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } 

我得到的零是每当我尝试从我的联系人列表页面回到原来的主页,所以它崩溃,并突出显示零行。 这个和上面的代表布尔都给我的问题。 任何澄清将非常感激,谢谢。

在你的AppDelegate.m中使用这个

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; HomeController *viewController = // initialise it self.window.rootViewController = viewController; [self.window makeKeyAndVisible]; return YES; } 

或者在storyBoard中只是将指向的错误放到你想作为一个根视图控制器的视图控制器上。

堆栈跟踪解释了什么是错的:

  • 终止应用程序由于未捕获的exception'NSInvalidArgumentException',原因:'无法find捆绑NSBundle(已装载)中名为'MainStoryboard'的故事板'

你的故事板不叫“MainStoryboard”。