728x90
240422
1. Navigation Controller 생성
가장 처음 보이는 화면과 연결 하는 코드
let vc = ViewController() // 가장 처음 보이는 controller
self.pushViewController(vc, animated: true) // 전체 화면으로 보이게 함
2. SceneDelegate에 RootView 등록
스토리보드 없는 codebase UI 셋팅은 ScenDelegate 파일에 아래 코드를 추가해 주었었다
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
window?.rootViewController = ViewController() // 원하는 뷰컨트롤러로 변경해주기
window?.makeKeyAndVisible()
네비게이션 컨트롤러를 연결하려면 rootViewController 에 NavigationController 를 생성해 준다
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
window?.rootViewController = MainNavigationController()
window?.makeKeyAndVisible()
상단에 네비게이션으로 <Back 이 생긴걸 볼 수 있다
버튼을 눌러서 다른 뷰로 이동하는건 다음 포스팅에서 다뤄보겠다
728x90
'iOS Swift > Study' 카테고리의 다른 글
Swift codebase UI 그리기 CollectionView (0) | 2024.04.25 |
---|---|
[codebase UI 그리기] Button 누를시 다른 view 로 화면전환 하기 (0) | 2024.04.22 |
To Do List 만들기 (1) alret 창 띄우고 할 일 적기 (0) | 2024.03.28 |
Swift 숫자 맞추기 게임 1 (1) | 2024.03.12 |
프로그래머스 Swift 자리수 더하기 (1) | 2024.03.12 |
댓글