How do I create a new Swift project without using Storyboards?

后端 未结 13 926
不知归路
不知归路 2020-11-29 15:47

Creating a new project in XCode 6 doesn\'t allow to disable Storyboards. You can only select Swift or Objective-C and to use or not Core Data.

I tried deleting the s

13条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 16:09

    If you want to Initialize your viewController with xib and and need to use navigation controller. Here is a piece of code.

    var window: UIWindow?
    var navController:UINavigationController?
    var viewController:ViewController?
    
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        window = UIWindow(frame: UIScreen.mainScreen().bounds)
    
        viewController = ViewController(nibName: "ViewController", bundle: nil);
        navController = UINavigationController(rootViewController: viewController!);
    
        window?.rootViewController = navController;
        window?.makeKeyAndVisible()
    
        return true
    }
    

提交回复
热议问题