在 Xcode 中显示第一个故事板场景的独特问题 [英] Unique Issue displaying first storyboard scene in Xcode
问题描述
我已经尝试了 2 天来让我的故事板显示此代码:
I have tried for 2 days now to get my storyboard to display with this code:
- (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'的故事板'
However, I keep getting this error and a sigbart in my main: 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'MainStoryboard' in bundle NSBundle (loaded)'
Google 中似乎没有出现关于这些错误的任何信息?有没有人知道如何解决它?
Nothing seems to appear in google about these errors? Does anyone have any idea how to fix it?
更新:当我将其更改为:
- (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] 如果应用程序委托要使用主故事板文件,它必须实现 window 属性.
it gives me the errors: [3208:c07] The app delegate must implement the window property if it wants to use a main storyboard file.
{AppDelegate setWindow:]:无法识别的选择器发送到实例 0x962bf30
{AppDelegate setWindow:]: unrecognized selector sent to instance 0x962bf30
[3208:c07] * 由于未捕获的异常NSInvalidArgumentException"而终止应用程序,原因:-[AppDelegate setWindow:]:发送到实例 0x962bf30 的无法识别的选择器"
[3208:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate setWindow:]: unrecognized selector sent to instance 0x962bf30'
推荐答案
终于找到了!!!!!!原来是我忘了把这行代码放在app委托头文件中:
Finally Found It!!!!!! Turns out that I forgot to put this line of code in the app delegate header file:
@property (strong, nonatomic) UIWindow *window;
这篇关于在 Xcode 中显示第一个故事板场景的独特问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!