ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • The Role of View Controllers (1) - Overview - View Controller Programming Guide for iOS
    iOS/๐ŸŽ Documentation 2021. 1. 14. 00:41
    ์ถœ์ฒ˜: Appple Develover Documentation [ View Controller Programming Guide for iOS ]

     

    View controllers๋Š” ์•ฑ ๋‚ด๋ถ€๊ตฌ์กฐ์˜ ๊ธฐ๋ณธ ์š”์†Œ์ž…๋‹ˆ๋‹ค.

    ๋Œ€๋ถ€๋ถ„์˜ ์•ฑ์€ ์—ฌ๋Ÿฌ ๊ฐœ์˜ View controller๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

    ๊ฐ๊ฐ์˜ View controller๋Š” ์•ฑ ๋‚ด ์กด์žฌํ•˜๋Š” UI ์ผ์ • ๋ถ€๋ถ„์”ฉ์„ ๋‹ด๋‹นํ•˜๊ณ  interactions ( ์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ ) ๋“ค์„ ๋‹ด๋‹นํ•ฉ๋‹ˆ๋‹ค.

    ๋˜ํ•œ ๋‹ค๋ฅธ UI๋กœ์˜ transition์„ ์šฉ์ดํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

     

    ์ฆ‰, View controller๋Š” ์•ฑ์—์„œ ์•„์ฃผ ์ค‘์š”ํ•œ ์—ญํ• ์„ ๋งก์Šต๋‹ˆ๋‹ค.

    UIKit์ด ์ œ๊ณตํ•˜๋Š” UIViewController ํด๋ž˜์Šค๋Š” View๋“ค์„ ๊ด€๋ฆฌํ•˜๊ณ  , ์ด๋ฒคํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ณ , ๋‹ค๋ฅธ View controller๋กœ ์ด๋™ํ•˜๊ณ  (transition)  ์•ฑ ๋‚ด์˜ ๋‹ค๋ฅธ ๋ถ€๋ถ„๋“ค๊ณผ ํ˜‘๋ ฅ (coordinate) ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๊ธฐ๋ณธ์ ์œผ๋กœ ๋ฉ”์„œ๋“œ์™€ ์†์„ฑ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

     

    ๋ณดํ†ต UIViewController๋ฅผ ์„œ๋ธŒ ํด๋ž˜์‹ฑ ํ•˜์—ฌ ๊ฐœ๋ฐœ์ž๊ฐ€ ์ž์‹ ์ด ๊ฐœ๋ฐœํ•˜๋Š” ์•ฑ ๋‚ด์—์„œ ํ•„์š”ํ•œ ์ปค์Šคํ…€ ์ฝ”๋“œ( ๋™์ž‘์„ ๊ตฌํ˜„ํ•˜๋Š” method, ํ•„์š”ํ•œ ์ •๋ณด๋ฅผ ๋‹ด์„ property)๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์™„์„ฑํ•ฉ๋‹ˆ๋‹ค.

     

    View contorller์—๋Š” 2๊ฐ€์ง€ ํƒ€์ž…์ด ์žˆ์Šต๋‹ˆ๋‹ค.

     

    1. Content view controllers (์ดํ•˜ Content VC)

    ํ•˜๋‚˜์˜ ๋ฃจํŠธ ๋ทฐ๋ฅผ ๊ฐ€์ง€๊ณ , ๊ทธ ์•ˆ์— ์„œ๋ธŒ ๋ทฐ๋“ค์ด ์กด์žฌํ•œ๋‹ค.

     

    2. Container view controllers (์ดํ•˜ Container VC)

    ๊ทธ ์ž์ฒด๋กœ ๋ฌด์—‡์„ ๋‚˜ํƒ€๋‚ด์ง€ ์•Š๋Š”๋‹ค. ๋Œ€์‹  Child view controllers ๋“ค์„ ๊ฐ€์ง€๊ณ  ์žˆ๊ณ  ๊ทธ๊ฒƒ๋“ค์˜ ์ •๋ณด๋กœ present ํ•œ๋‹ค.

     

    ๋Œ€๋ถ€๋ถ„์˜ ์•ฑ๋“ค์€ ์ด๊ฒƒ๋“ค์˜ ์กฐํ•ฉ์œผ๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค.

    ์˜ˆ๋ฅผ ๋“ค์–ด Container VC์˜  Child VC๋Š” ๋ณดํ†ต Content VC๋“ค๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๋Š” ํ˜•ํƒœ์ž…๋‹ˆ๋‹ค.

     


     

    View Management

     

    ๋ชจ๋“  VC ๋Š” ๋‹จ ํ•˜๋‚˜์˜ root view๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

    ์ด root view๋Š”  ํ•ด๋‹น VC์˜ ๋ชจ๋“  ์ฝ˜ํ…์ธ ๋ฅผ ํฌํ•จ (encloses) ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

     

    ์ด root view ์•„๋ž˜ ๊ณ„์ธต์— view๋“ค์„ ์ถ”๊ฐ€ํ•ด์„œ ํ™”๋ฉด์— ๋ณด์—ฌ์ค„ ์ฝ˜ํ…์ธ ๋ฅผ ๋„์›๋‹ˆ๋‹ค.

     

    View controller์™€  ๊ทธ๊ฒƒ์— ์†ํ•œ view๋“ค์˜ ๊ด€๊ณ„

    ๋ณดํ†ต outlet์„ ์‚ฌ์šฉํ•ด์„œ VC ๊ณ„์ธต์— ์กด์žฌํ•˜๋Š” View๋“ค์— ์ ‘๊ทผํ•ฉ๋‹ˆ๋‹ค.

     

    Content VC๋Š” ๊ทธ ๊ณ„์ธต์— ํฌํ•จ๋œ ๋ชจ๋“  View ๋“ค์„ ์ง์ ‘ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

     

    Container VC๋Š” ์ž์ฒด ๋ทฐ์™€ ํ•˜๋‚˜ ํ˜น์€ ์—ฌ๋Ÿฟ์ด ๋  ์ˆ˜ ์žˆ๋Š” Child view controller์˜ root view ๋งŒ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

    Container VC๋Š” child์˜ ์ฝ˜ํ…์ธ ๋ฅผ ๊ด€๋ฆฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. Child์˜ root view ๋งŒ์„ ๊ด€๋ฆฌํ•˜๋ฉฐ, Container ๋””์ž์ธ์— ๋งž๋„๋ก ํฌ๊ธฐ ์กฐ์ ˆ๊ณผ ์œ„์น˜ ์กฐ์ •์„ ํ•ฉ๋‹ˆ๋‹ค.

     

    ์˜ˆ๋กœ Split View Controller๋ฅผ ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ์ด๊ฒƒ์€ Container View๋กœ, ์ž์ฒด์˜ ๋ทฐ์ธ Spit View Container View๋ฅผ ๊ด€๋ฆฌํ•˜๊ณ , ์ด๊ฒƒ์˜ ๋””์ž์ธ์— ๋งž๊ฒŒ Child VC ๋“ค์˜ ์‚ฌ์ด์ฆˆ ๋ฐ ์œ„์น˜๋ฅผ ์กฐ์ ˆํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

     

    Container view controller์˜ ์˜ˆ์‹œ

     

     

     

    ๋!


    ๋‹ค์Œ ๊ธ€: The Role of View Controllers (2) - Overview - View Controller Programming Guide for iOS

     

    The Role of View Controllers (2) - Overview - View Controller Programming Guide for iOS

    ์ถœ์ฒ˜ : Apple Developer Documentation Data Marshaling marshal = organize View controllers (์ดํ•˜ VC)๋Š” ๊ทธ ๊ณ„์ธต์— ์žˆ๋Š” view ๋“ค๊ณผ ์•ฑ์—์„œ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐ์ดํ„ฐ๋“ค์˜ ์ค‘๊ณ„์ž (intermediary)์ž…๋‹ˆ๋‹ค. UIViewController..

    woozzang.tistory.com

     

    ๋Œ“๊ธ€

์–ด์ œ๋ณด๋‹ค ๋ฐœ์ „ํ•œ ๋‚˜