当前位置: 代码迷 >> 综合 >> xcode7 创建新工程
  详细解决方案

xcode7 创建新工程

热度:10   发布时间:2024-01-04 12:05:02.0

最近用xcode7.1.1 新建了一个工程,工程里默认有 UISplitViewController 等类的创建。查看Main.storbBoard 发现,里边默认用的就是 SplitViewController 。但是这不是我想要的。我想自己写入口。

之前 是这样

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

    UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;

    UINavigationController *navigationController = [splitViewController.viewControllers lastObject];

    navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;

    splitViewController.delegate = self;

    return YES;

}


后来我删除了storyboard,删除了didfinishLaunching 里边的代码(return YES)除外。新建了一个VC。然后xib同时创建。之后在didfinishlaunching里边写:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

    

    _window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

    self.window.backgroundColor = [UIColor redColor];

    [_window makeKeyAndVisible];

    

    RXScrollViewViewController *mVC = [[RXScrollViewViewController alloc]initWithNibName:@"RXScrollViewViewController" bundle:[NSBundle mainBundle]];

    self.window.rootViewController = mVC;

    

    return YES;

}



这样运行,发现会崩溃。

报错为

test[46315:616190] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Main' in bundle NSBundle </Users/red/Library/Developer/CoreSimulator/Devices/26AE60B2-3302-407F-949B-805BF6AB486F/data/Containers/Bundle/Application/41A7AEFA-96CC-4F1A-BFF0-4365E39463EA/test.app> (loaded)'



因为plist里边有个属性,是设置加载main.storyboard的。故需要删除 Main storyboard file base name属性,或者 属性后边string 类型的置为空。运行,搞定。


适合初学者,小事有可能导致大家很耗时