iOS 13: Swift - 'Set application root view controller programmatically' does not work

后端 未结 14 1060
北恋
北恋 2020-12-01 01:43

I have following code in my AppDelegate.swift to setup root view controller for an iOS application. But it does not work. It follows Target structure (defined under General

14条回答
  •  春和景丽
    2020-12-01 02:33

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    
        guard let windowScene = (scene as? UIWindowScene) else { return }
        self.window = UIWindow(windowScene: windowScene)               
          self.window?.makeKeyAndVisible()
    
        let layout = UICollectionViewFlowLayout()
        let swipingController = SwipingController(collectionViewLayout: layout)
              self.window?.rootViewController = swipingController       
    
    }
    

提交回复
热议问题