处理这个布尔值的正确方法是什么? [英] What is the correct way to proceed with this bool?

查看:30
本文介绍了处理这个布尔值的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have this bool in my 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;
    }

我在 *storyboard 上遇到了一个错误,但我主要想做的是在与主视图控制器不同的视图控制器中初始化应用程序.我拥有所有带有 ID 的视图控制器(例如我要启动的视图控制器名为Home").如果说我的 ViewController ID 是 home,我将如何正确编写这个 bool?

I'm getting an error on the *storyboard but what I am mainly trying to do is initialize the application in a different view controller than the main one. I have all the view controllers with IDs (such as the one I want to launch is named "Home"). How would I correctly write this bool if say my ViewController ID was home?

我的 main.m:

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char * argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

当我尝试从我的联系人列表页面返回原始主页时,我得到的 nil 会崩溃并突出显示 nil 行.这个和上面的委托布尔都给我带来了问题.任何澄清将非常感谢,谢谢.

The nil I get is whenever I try to go back to the original Home page from my Contact list page so it crashes and highlights the nil line. Both this and the above delegate bool are giving me issues. Any clarification would be very much appreciated, thanks.

推荐答案

堆栈跟踪说明出了什么问题:

The stack trace explains what's wrong:

  • 由于未捕获的异常NSInvalidArgumentException"而终止应用程序,原因:找不到情节提要"在包 NSBundle(已加载)中命名为MainStoryboard"*

您的故事板不称为MainStoryboard".

Your storyboard isn't called "MainStoryboard".

这篇关于处理这个布尔值的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆