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

后端 未结 13 931
不知归路
不知归路 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:15

    Try the following code:

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
        self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
        self.window!.backgroundColor = UIColor.whiteColor()
    
        // Create a nav/vc pair using the custom ViewController class
    
        let nav = UINavigationController()
        let vc = NextViewController ( nibName:"NextViewController", bundle: nil)
    
        // Push the vc onto the nav
        nav.pushViewController(vc, animated: false)
    
        // Set the window’s root view controller
        self.window!.rootViewController = nav
    
        // Present the window
        self.window!.makeKeyAndVisible()
        return true
    
    }
    

提交回复
热议问题