본문 바로가기
🍎 iOS

[Swift] UINavigationController 사용하기

by 틴디 2020. 9. 8.
728x90
반응형

 

🍪 Storyboard 에서 임베드 하기

Storyboard > Editor > Embed in > Navigation Controller

🍪 Programmatically

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        self.window = UIWindow(frame: UIScreen.main.bounds)
        
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let itemsController = storyboard.instantiateViewController(withIdentifier: "ItemsViewController") as! ItemsViewController

        
        let rootViewController = UINavigationController(rootViewController: itemsController)
        
        window?.rootViewController = rootViewController
        window?.makeKeyAndVisible()
        

        return true
    }

    

}

 

window의 rootViewCotroller를 UINavigationController로 지정해 주면 됩니다.

728x90
반응형

댓글