์ฃผ๋ก ์์ดํจ๋์์ ์ฌ์ฉ
- preferredContentSize: ๋์ด์ค ๋ทฐ์ ์ฌ์ด์ฆ๋ฅผ ์ ํจ
- popoverPresentationController.sourceView: ๋์ธ ๋ถ๋ชจ ๋ทฐ
- popoverPresentationController.sourceRect: ์ด๋์ ๋์ธ์ง
Trouble ๐

๋ค์๊ณผ ๊ฐ์ ๋ถ๋ฆฌ๋ ๋ทฐ์ปจ์์ ๋ทฐ๋ฅผ ๋์ฐ๋ ๊ฑธ ํ์ง ๋ง๋ผ๊ณ ํ๋ค
https://developer.apple.com/forums/thread/29787
์ด๊ฑธ ๋ณด๊ณ
self.view.window?.rootViewController?.present(popoverViewController, animated: false)
๋ฐฉ์์ผ๋ก ๋์ฐ๋๊น ์ค๋ฅ๊ฐ ํด๊ฒฐ๋๋ค
Displaying transient content in a popover
- ๋ทฐ์ปจํธ๋กค๋ฌ๋ฅผ ์ฌ์ฉํ์ฌ ์ง์
- popover presentation style ์ ์ฌ์ฉํ์ฌ ๋ทฐ์ปจํธ๋กค๋ฌ๋ฅผ ํ์(modalPresentationStyle์ ์ค์ )
- UIKit์ ํ์ค๋ฒ๋ฅผ ์ง์ ํ ์์น์ ๊ณ ์ ์ํด
- ๋ทฐ ์ปจํธ๋กค๋ฌ์ UIPopoverPresentationController๊ฐ ํ๋ฉด์ ํ์ค๋ฒ๋ฅผ ํ์ํ๋ ๊ฒ์ ๊ด๋ฆฌํจ
- present ๋ฉ์๋๋ฅผ ํธ์ถ ํ๊ธฐ ์ ์ ๋ทฐ์ปจํธ๋กค๋ฌ์ UIPopoverPresentationController ๊ฐ์ฒด์ ํ๋กํผํฐ๋ฅผ ๊ตฌ์ฑํด์ผํจ
- ํ์ค๋ฒ์ ํ์์ ํด์ ๋ฅผ ๊ด๋ฆฌํ๊ธฐ ์ํด ๋ธ๋ฆฌ๊ฒ์ดํธ๋ฅผ ํ ๋น ํ ์ ์์
H.I.G
- ์ฌ๋๋ค์ด ์ปจํธ๋กค์ด๋ ๋ํํ ์์ญ์ ํด๋ฆญํ๊ฑฐ๋ ํญํ ๋ ๋ค๋ฅธ ์ฝํ
์ธ ์์ ๋ํ๋๋ ์ผ์์ ์ธ ๋ณด๊ธฐ
- ์๋์ ์ ๋ณด๋ ๊ธฐ๋ฅ์ ๋
ธ์ถํ ๋ ์ฌ์ฉ
- ํ์ํ ๋ช ๊ฐ์ง ์์
๋ง์ ์ํํ ์ ์๋๋ก ๊ธฐ๋ฅ์ ์ ๊ณตํด์ผ ํจ
- ์ฝํ
์ธ ๋ฅผ ์ํ ๋ ๋ง์ ๊ณต๊ฐ์ด ํ์ํ ๊ฒฝ์ฐ ํ์ค๋ฒ ์ฌ์ฉ์ด ๋ง๋์ง ๊ณ ๋ คํด ๋ด์ผํจ
- ์ฝํ
์ธ ๊ฐ ์ผ์์ ์ผ๋ก๋ง ํ์๋ก ํ๋ ๊ฒฝ์ฐ, ์ธํฐํ์ด์ค๋ฅผ ๊ฐ์ํํ๋ ๋ฐ ๋์์ด ๋ ์ ์์
- Popover์ ํ์ดํ๊ฐ ๊ฐ๋ฅํ ์ ํํ๊ฒ ์์๋ฅผ ๊ฐ๋ฆฌํค๋๋ก ํด์ผํจ
- ์ด์์ ์ธ Popover๋ Popover ์ฌ์ฉ ์ค ์ฌ๋๋ค์ด ๋ณผ ์ ์์ด์ผ ํ ์ค์ ์ปจํ
์ธ ๋ฅผ ๊ฐ๋ฆฌ์ง ์์์ผ ํจ
- ๋ซ๊ธฐ ๋ฒํผ์ ํ์ธ ๋ฐ ์๋ด ๋ชฉ์ ์ผ๋ก๋ง ์ฌ์ฉํด์ผํจ
UIPopoverPresentationController
@MainActor
class UIPopoverPresentationController : UIPresentationController
- ํ์ค๋ฒ์์ ์ฝํ
์ธ ์ ํ์๋ฅผ ๊ด๋ฆฌํ๋ ๊ฐ์ฒด
- ํ์ค๋ฒ๊ฐ ํ์๋ ์์ ๋ถํฐ ํด์ ๋ ๋๊น์ง UIKit์ ์ด ํด๋์ค์ ์ธ์คํด์ค๋ฅผ ์ฌ์ฉํ์ฌ ํ์ ๋์์ ๊ด๋ฆฌํจ
- UIModalPresentationStyle.popover๋ก ์ค์ ๋ ๋ทฐ ์ปจํธ๋กค๋ฌ์ ํ์ค๋ฒ ์ธ๊ด ๋ฐ ๋์์ ๊ตฌ์ฑํจ
- ๋๋ถ๋ถ์ ๊ฒฝ์ฐ ์ด ํด๋์ค๋ฅผ ๊ทธ๋๋ก ์ฌ์ฉํ๊ณ ์ด ํด๋์ค์ ์ธ์คํด์ค๋ฅผ ์์ฑํ์ง ์์
- UIKit์ UIModalPresentationStyle.popover ๋ก ๋ทฐ์ปจํธ๋กค๋ฌ๋ฅผ ํ์ํ ๋ ์๋์ผ๋ก ์ด ํด๋์ค์ ์ธ์คํด์ค๋ฅผ ์์ฑํจ
- ํ์๋ ๋ทฐ ์ปจํธ๋กค๋ฌ์ popoverPresentationController ์ ์์ฑ์ผ๋ก ํ์ค๋ฒ์ ๋์์ ๊ตฌ์ฑํ ์ ์์
์ถ์ฒ๐
๐Apple H.I.G: Popovers
๐Apple Docs: Displaying transient content in a popover
๐Apple Docs: UIPopoverPresentationController