Skip to content

Latest commit

ย 

History

History
60 lines (34 loc) ยท 3.58 KB

UIWindow.md

File metadata and controls

60 lines (34 loc) ยท 3.58 KB

UIWindow ๊ฐ์ฒด์˜ ์—ญํ• ์€ ๋ฌด์—‡์ธ๊ฐ€

๋„์›€์„ ์ค€ ์ข‹์€ ๋ธ”๋กœ๊ทธ

์‚ฌ์ „์ง€์‹

Answer

UIWindow๋ฅผ ์„ค๋ช…ํ•˜๋Š” ๊ทธ๋ฆผ

์œ„ ๊ทธ๋ฆผ์„ ๋ณด๋ฉด UIWindow๊ฐ€ UIView์˜ ๋ถ€๋ชจ๋ผ๋Š” ๋Š๋‚Œ์„ ๋งค์šฐ ๋งŽ์ด ์ฃผ๊ณ  ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ์‹ค์ œ๋กœ๋Š” ๊ทธ๋ ‡์ง€ ์•Š๋‹ค!

image

UIWindow์˜ Definition์„ ์‚ดํŽด๋ณด๋ฉด ์˜คํžˆ๋ ค UIWindow์˜ ๋ทฐ๋ชจ๊ฐ€ UIView์ธ ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

๊ณต์‹ ๋ฌธ์„œ ์ฝ์–ด๋ณด๊ธฐ

๊ณต์‹ ๋ฌธ์„œ๋ฅผ ์‚ดํŽด๋ณด๋ฉด UIWindow๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ์ •์˜๋˜์–ด์žˆ๋‹ค.

"The backdrop for your appโ€™s user interface and the object that dispatches events to your views."

APP์˜ UI์— ๋Œ€ํ•œ ๋ฐฐ๊ฒฝ์ด๋ฉฐ View์— ์ด๋ฒคํŠธ๋ฅผ ์ „๋‹ฌํ•˜๋Š” ๊ฐœ์ฒด์ž…๋‹ˆ๋‹ค.

"Windows work with your view controllers to handle events and to perform many other tasks that are fundamental to your appโ€™s operation. UIKit handles most window-related interactions, working with other objects as needed to implement many app behaviors."

Window๋“ค์€ ์ด๋ฒคํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ณ  ๋งŽ์€ ์•ฑ ์‹คํ–‰์˜ ๊ธฐ๋ณธ์ด ๋˜๋Š” ์ž‘์—…๋“ค์„ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•ด ViewController์™€ ํ•จ๊ป˜ ์ž‘๋™ํ•œ๋‹ค. UIKit์€ ๋Œ€๋ถ€๋ถ„์˜ Window ๊ด€๋ จ ์ƒํ˜ธ์ž‘์šฉ์„ ์ฒ˜๋ฆฌํ•˜๊ณ , ์•ฑ ๋™์ž‘์„ ๊ตฌํ˜„ํ•˜๋Š” ๋ฐ ํ•„์š”ํ•œ ๋‹ค๋ฅธ ๊ฐ์ฒด๋“ค๊ณผ ์ž‘๋™ํ•œ๋‹ค.

์•ฑ์€ ํ•„์ˆ˜์ ์œผ๋กœ ์ฝ˜ํ…์ธ ๋ฅผ ํ‘œ์‹œํ•  ๊ธฐ๋ณธ Window๋ฅผ ์ œ๊ณตํ•ด์•ผํ•˜๋Š”๋ฐ, ์ด๋ฅผ Xcode๊ฐ€ ๋Œ€์‹  ์ œ๊ณตํ•ด์ค๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•˜๊ณ ๋‚˜๋ฉด ๋ณ„๋„์˜ ์ž‘์—… ์—†์ด๋„ AppDelegate(iOS 13๋ถ€ํ„ฐ๋Š” SceneDelegate) ๋‚ด๋ถ€์— window ์†์„ฑ์ด ์žˆ๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋Š”๊ฑด๊ฐ€๋ด์š”!

์ œ๊ฐ€ UIWindow๋ฅผ ๊ฑด๋“œ๋ ธ๋˜ ๊ฑด

  1. Window์˜ Root View Controller๋ณ€๊ฒฝ
  2. Window๊ฐ€ ํ‘œ์‹œ๋˜๋Š” ์Šคํฌ๋ฆฐ ๋ณ€๊ฒฝ

์ด ๋‘๊ฐ€์ง€ ์˜€๋Š”๋ฐ ์ด ๋‘๊ฐ€์ง€ ๋ง๊ณ ๋„ ์•„๋ž˜์™€ ๊ฐ™์€ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

  1. ๋‹ค๋ฅธ window๋“ค๊ณผ์˜ ๊ฐ€์‹œ์„ฑ์— ์˜ํ–ฅ์„ ์ฃผ๋Š” window์˜ z์ถ• level ์„ค์ •
  2. window๋ฅผ ํ‘œ์‹œํ•˜๊ณ  ํ‚ค๋ณด๋“œ ์ด๋ฒคํŠธ์˜ ๋Œ€์ƒ์œผ๋กœ ๋งŒ๋“ค๊ธฐ
  3. ์ขŒํ‘œ ๊ฐ’์„ window์˜ ์ขŒํ‘œ๊ณ„๋กœ, ํ˜น์€ ๊ทธ ๋ฐ˜๋Œ€๋กœ ๋ณ€ํ™˜

"Windows do not have any visual appearance of their own. Instead, a window hosts one or more views, which are managed by the window's root view controller."

Window๋Š” ์ž์‹ ๋งŒ์˜ ์–ด๋–ค ๋ชจ์–‘์ด ์žˆ๋Š” ๊ฒƒ์€ ์•„๋‹ˆ์ง€๋งŒ, window๋Š” window์˜ ๋ฃจํŠธ ๋ทฐ์ปจ์— ์˜ํ•ด ๊ด€๋ฆฌ๋˜๋Š” ํ•˜๋‚˜ ํ˜น์€ ๊ทธ ์ด์ƒ์˜ ๋ทฐ๋“ค์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  UIWindow ๊ฐ์ฒด๋ฅผ ํ•˜์œ„ ํด๋ž˜์Šค๋กœ ๋‘๋Š” ๊ฒฝ์šฐ๋Š” ๊ทนํžˆ ๋“œ๋ฌผ๋‹ค๊ณ  ํ•ด์š”. ์ƒ์œ„ ๋ ˆ๋ฒจ ViewController์—์„œ ๋” ์‰ฝ๊ฒŒ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋ž˜์š”. ํ•˜์œ„ ํด๋ž˜์Šค๋กœ ์ง€์ •ํ•˜๊ฒŒ ๋˜๋Š” ๋ช‡ ๊ฐ€์ง€ ๊ฒฝ์šฐ ์ค‘ ํ•˜๋‚˜๋Š” window์˜ ํ‚ค ์ƒํƒœ๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ ์‚ฌ์šฉ์ž ์ง€์ • ๋™์ž‘์„ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•ด becomeKey() ๋˜๋Š” registeredKey() ๋ฉ”์„œ๋“œ๋ฅผ ์žฌ์ •์˜ํ•  ๋•Œ ์ •๋„๋ผ๊ณ  ํ•˜๋„ค์š”!

์š”์•ฝ

  • iOS์•ฑ์€ ๋ชจ๋“  View๋“ค์˜ ์ปจํ…Œ์ด๋„ˆ ์—ญํ• ์„ ํ•˜๋Š” UIWindow ์ธ์Šคํ„ด์Šค๋ฅผ ๊ฐ€์ง„๋‹ค.
  • UIWindow๋Š” UIView์˜ ํ•˜์œ„ํด๋ž˜์Šค์ด๋‹ค.
  • ๊ทธ๋Ÿฌ๋ฏ€๋กœ UIWindow๋Š” ๊ทธ ์ž์ฒด๋งŒ์œผ๋กœ View์ด๋‹ค.
  • window์€ ๋ชจ์–‘์ด ์žˆ๋Š”๊ฑด ์•„๋‹ˆ์ง€๋งŒ ๋ฃจํŠธ ๋ทฐ์ปจ ์ดํ•˜์˜ ๋งŽ์€ ๋ทฐ๋“ค์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค.
  • window๋ฅผ ํ•˜์œ„ ํด๋ž˜์Šค๋กœ ๋‘๋Š” ๊ฒฝ์šฐ๋Š” ๋“œ๋ฌผ๋‹ค.