์ƒ์„ธ ์ปจํ…์ธ 

๋ณธ๋ฌธ ์ œ๋ชฉ

SceneDelegate์—์„œ navigationController ์„ค์ •

๐ŸŽ iOS/Swift

by AHN.Jihyeon 2024. 8. 4. 18:17

๋ณธ๋ฌธ

import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    
    var window: UIWindow?    // ์•ฑ์„ ์‹œ์ž‘ํ• ๋•Œ ์„ธํŒ…ํ•ด์ค„ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๊ณณ.
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // UIWindow ๊ฐ์ฒด ์ƒ์„ฑ.
        guard let windowScene = (scene as? UIWindowScene) else { return }
        let window = UIWindow(windowScene: windowScene)
        

        //์ดˆ๊ธฐ ๋ทฐ ์ปจํŠธ๋กค๋Ÿฌ ์„ค์ •
        var navigationController = UINavigationController(rootViewController: MainViewController())
        window.rootViewController = navigationController
        // ์ด ๋ฉ”์„œ๋“œ๋ฅผ ๋ฐ˜๋“œ์‹œ ์ž‘์„ฑํ•ด์ค˜์•ผ ์œˆ๋„์šฐ๊ฐ€ ํ™œ์„ฑํ™” ๋จ.
        window.makeKeyAndVisible()
        self.window = window
    }
    
    
}

 

 

 

๊ด€๋ จ๊ธ€ ๋”๋ณด๊ธฐ