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

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

    I have found the answer it had nothing to do with the xcode setup, removing storyboard and the reference from project is the right thing. It had to do with the swift syntax.

    The code is the following:

    class AppDelegate: UIResponder, UIApplicationDelegate {
    
    var window: UIWindow?
    var testNavigationController: UINavigationController?
    
        func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
    
            self.testNavigationController = UINavigationController()
            var testViewController: UIViewController? = UIViewController()
            testViewController!.view.backgroundColor = UIColor.redColor()
            self.testNavigationController!.pushViewController(testViewController, animated: false)
    
            self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
    
            self.window!.rootViewController = testNavigationController
    
            self.window!.backgroundColor = UIColor.whiteColor()
            self.window!.makeKeyAndVisible()
    
            return true
        }
    
    }
    

提交回复
热议问题