ViewController๋Š” ๊ณ„์ธต์„ ์ด๋ฃจ๋ฉด์„œ ๊ตฌ์„ฑ๋œ๋‹ค. ๊ทธ ์ค‘ ๋Œ€ํ‘œ์ ์œผ๋กœ ์•Œ๋ ค์ง„ ๊ฒƒ์ด NavigationController, TabBarController ์ด๋‹ค. ์˜ค๋Š˜์€ ๊ณ„์ธต์ด ์–ด๋–ป๊ฒŒ ๊ตฌ์„ฑ๋˜์—ˆ๋Š”์ง€ ๊ฐ„๋‹จํ•˜๊ฒŒ ์•Œ์•„๋ณด๊ณ , ๊ตฌ์ฒด์ ์œผ๋กœ๋Š” NaviagtionController์™€ TabBarController๋ฅผ ์•Œ์•„๋ณด๋ ค ํ•œ๋‹ค. ๊ทธ๋Ÿผ ์‹œ์ž‘ํ•ด๋ณด์ž.

ViewController ๊ณ„์ธต

  • Modal, Push, Pop ๋“ฑ viewController๋Š” ์ž์‹  ์œ„, ํ˜น์€ ์•„๋ž˜์— ๋‹ค๋ฅธ ViewController๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์žˆ์Œ
  • presenting, presented, parent, child ๋“ฑ์˜ ๊ด€๊ณ„๋ฅผ ๊ฐ€์ง
  • ๊ณ„์ธต ๊ตฌ์กฐ๊ฐ€ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— UIApplication ๊ฐ์ฒด ๋‚ด์— ์กด์žฌํ•˜๋Š” ๋ชจ๋“  VC๋ฅผ ํƒ์ƒ‰ํ•˜๋Š” ๊ฒƒ์ด ๊ฐ€๋Šฅ

Responder Chain

  • ๊ณ„์ธต ๊ตฌ์กฐ์˜ ๋ฐ˜๋Œ€๋กœ (๊ฐ€์žฅ ์ƒ์œ„์— ์˜ฌ๋ผ์™€ ์žˆ๋Š” View ๋ถ€ํ„ฐ ํ•˜์œ„๋กœ) ์ง„ํ–‰ํ•˜๋ฉด์„œ, ์ด๋ฒคํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ณ  ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ๋„˜๊ธฐ๋Š” ๋ฐฉ์‹
  • UIApplication์œผ๋กœ ์ตœ์ข… event๊ฐ€ ๋น ์ง€๋Š” ํ˜•ํƒœ์ด๋‹ค.

UIKit ์ œ๊ณต Container View Controller

UISplitViewController

UIPageViewController

  • UIPageViewController
  • ์‚ฌ์šฉ์ž ์ œ์Šค์ฒ˜ ํ˜น์€ ์ฝ”๋“œ๋กœ ํ•œ ํ™”๋ฉด์—์„œ ๋‘๊ฐœ ์ด์ƒ์˜ ViewController ์ปจํ…์ธ ๋ฅผ ๋™์‹œ ํ‘œํ˜„ ๊ฐ€๋Šฅ
  • Scroll, Page Curl ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ง€์›
  • ์—ฌ๋Ÿฌ๊ฐœ ViewController๋ฅผ Child๋กœ ๊ฐ€์ง
  • Parent-Child ๊ตฌ์กฐ๋ฅผ ๊ฐ€์ง

UINavigationController

  • Stack ๊ธฐ๋ฐ˜์˜ Container View Controller
  • push, pop

  • viewControllers
  • NavigationBar
    • left item
      • rootViewController๋ฅผ ์ œ์™ธํ•œ ๋ชจ๋“  Child ViewController์— Back ๋ฒ„ํŠผ ์ œ๊ณต๋จ
        • ๊ธฐ๋ณธ์ ์œผ๋กœ ์ด์ „ ViewController์˜ ์ œ๋ชฉ์œผ๋กœ ์ƒ์„ฑ๋จ
      • Customํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ backBarButtonItem์œผ๋กœ ์„ค์ •
    • middle item
      • navigationItem.title, navigationItem.prompt
      • ๊ธฐ๋ณธ์ ์œผ๋กœ ํ•ด๋‹น ViewController์˜ title ์ด ํ‘œ์‹œ๋จ
      • Customํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด navigationItem.titleView ์„ค์ •
    • right item
      • navigationItem.rightBarButtonItem
      • ์„ค์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ํ‘œ์‹œ X
  • toolBar
    • Tool bar ๋Š” ํ˜„์žฌ content ์—์„œ ํ•  ์ˆ˜ ์žˆ๋Š” ์กฐ์ž‘์„ ๋ณด์—ฌ์ฃผ๋Š” bar
  • delegate
    • NavigatinController์˜ Life Cycle
    • ํšŒ์ „
    • Transition
    • ํŠน์ • VC์—์„œ ํšŒ์ „ ์˜ˆ์™ธ ๋ฃฐ ์ ์šฉ
    • ์„œ๋ธŒ ํด๋ž˜์‹ฑ ํ›„, supportedInterfaceOrientations ์˜ค๋ฒ„๋ผ์ด๋”ฉํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ๊ฐ€๋Šฅ
    • NavigationController avigationControllerSupportedInterfaceOrientations
    • UIViewController supportedInterfaceOrientations
    • ์˜ˆ์‹œ
      • Nav โ†’ A โ†’ B โ†’ C

      • A๋Š” potrait, B, C๋Š” landscape๋„ ์ง€์›ํ•˜๊ณ  ์‹ถ์Œ

      • Navigation Controller์—์„œ topViewController ์ ‘๊ทผ ํ›„, ํ•ด๋‹น ViewController๊ฐ€ ํšŒ์ „ ๊ณ ์ •์„ ์–ด๋–ป๊ฒŒ ํ–ˆ๋Š”์ง€ ํ™•์ธํ•˜์—ฌ Navigation Controller์—ญ์‹œ ๋Œ๋ฆฌ๋Š” ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉ

      • ViewController ํšŒ์ „ ๋ฐฉํ–ฅ์— ๋”ฐ๋ผ Navigation Controller์˜ ๋ฐฉํ–ฅ๋„ ๋Œ๋ ค์ค˜์•ผ ํ•œ๋‹ค๋Š” ๊ฒƒ์ด ํฌ์ธํŠธ

        // ๋Œ๋ฆฌ๊ณ  ์‹ถ์ง€ ์•Š์€ VIewController
        override var supportedInterfaceOrientations: UIInterfaceOritentationMask {
            return .potrait
        }
         
        override var shouldAutorotate: Bool {
            return true
        }
        // NavigationControllerDelegate ์ฑ„ํƒ ๊ฐ์ฒด
        func navigationControllerSupportedInterfaceOrientations(_ navigationController: UINavigationController) -> UIInterfaceOrientationMask {
            return (navigationController.topViewController?.supportedInterfaceOrientations ?? .all
        }
        • ํšŒ์ „์„ ํ•˜๊ณ  ์‹ถ์€ VC์—๋งŒ ๊ฐ’์„ overrideํ•˜์—ฌ ํšŒ์ „์„ ํ•˜๋„๋ก ๋งŒ๋“ค ์ˆ˜ ์žˆ์Œ

Transition์‹œ ViewController ํ˜ธ์ถœ ์ˆœ์„œ

A โ†’ B Push์˜ ๊ฒฝ์šฐ ์œ„์™€ ๊ฐ™์€ ์ˆœ์„œ๋กœ ๋™์ž‘ํ•œ๋‹ค.

pop์˜ ๊ฒฝ์šฐ ์œ„์™€ ๊ฐ™์€ ์ˆœ์„œ๋กœ ๋™์ž‘ํ•œ๋‹ค.

Reference