starting ios project without storyboard

前端 未结 9 1238
渐次进展
渐次进展 2021-01-12 23:28

Im having some troubles to start an iOS app using xibs instead of storyboard. The problem is that im getting a black screen and the first view controller is not being called

9条回答
  •  天涯浪人
    2021-01-13 00:00

    In Swift 3.0

    //MARK: Initial View Controller
    func initialViewController(){
        self.window = UIWindow(frame: UIScreen.main.bounds)
        let rootViewController = UIViewController(nibName: "HomeVC", bundle: nil)
        let navigation : UINavigationController = UINavigationController(rootViewController: rootViewController)
        navigation.isNavigationBarHidden = true
        self.window?.rootViewController = navigation
        self.window?.makeKeyAndVisible()
    }
    

    in appdelegate.swift

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    
        initialViewController()
    
        return true
    }
    

提交回复
热议问题