iOS
[iOS] Storyboard 없이 ViewController 연결하기
_보름
2021. 7. 9. 22:04
1. Main Interface 삭제
Main.Storyboard
파일을 삭제합니다.
그 후 Main Interface
를 빈칸으로 만듭니다.
2. Info.plist의 Storyboard Name 삭제
Storyboard Name
의 ⊖ 버튼을 눌러서 삭제합니다.
3. SceneDelegate.swift에 코드 추가
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let scene = (scene as? UIWindowScene) else { return }
self.window = UIWindow(windowScene: scene)
self.window?.rootViewController = ViewController()
self.window?.makeKeyAndVisible()
}
self.window.rootViewController
를 원하는 컨트롤러로 설정해주면 Storyboard 없이 ViewController가 연결됩니다.