본문 바로가기
iOS/iOS

스토리보드 없이 코드로 뷰 구현하기

by 패쓰킴 2021. 10. 26.
728x90

1.스토리보드 파일을 삭제

2.SceneDelegate파일에서 scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) 함수에 윈도우 설정을 위한 코드를 작성

   // 뷰를 스토리보드 없이 만들 때 준비
   // 윈도우를 새롭게 초기화 하는 과정
   guard let windowScene = (scene as? UIWindowScene) else { return }
   window = UIWindow(windowScene: windowScene)
   window?.backgroundColor = .systemBackground
   window?.rootViewController = UINavigationController(rootViewController: StationSearchViewController())
   // window가 여러개 존재할 때, 가장 앞쪽에 배치된 window를 `key window`라고 지칭
   // 지정한 rootViewController가 상호작용을 받는 현재 화면으로 세팅
   window?.makeKeyAndVisible()


3.Info.plist에서 Application Scene Manifest의 'Storyboard Name'과 'Main Storyboard file base name' 삭제

728x90

'iOS > iOS' 카테고리의 다른 글

네트워크 통신 주의점  (0) 2021.12.03
UIPickerView - 항목 설정  (0) 2021.10.29
네트워크 통신 - inof.plist 설정  (0) 2021.10.26
firebase로 APNs - FCM  (0) 2021.10.22
firebase로 애플 로그인  (0) 2021.10.12

댓글