独特的问题显示Xcode中的第一个故事板场景
我已经尝试了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',原因:'无法find一个名为'MainStoryboard'捆绑NSBundle(加载)“
谷歌似乎没有出现这些错误? 有没有人有任何想法如何解决它?
更新:当我将其更改为:
- (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]应用程序委托必须实现窗口属性,如果它想要使用主故事板文件。
{AppDelegate setWindow:]:无法识别的select器发送到实例0x962bf30
[3208:c07] *由于未捕获exception'NSInvalidArgumentException',原因:' – [AppDelegate setWindow:]:无法识别的select器发送到实例0x962bf30'
终于find了!!!!!! 原来,我忘了把这行代码放在应用程序委托头文件中:
@property (strong, nonatomic) UIWindow *window;