์ผ๋ฟ(Alert)
์ฌ์ฉ์์๊ฒ ์ค์ํ ์๋ฆผ์ด๋ ๊ฒฝ๊ณ ๋ฉ์์ง๋ฅผ ๋ํ๋ด์ผ ํ ๋ ์ฌ์ฉํ๋ ๊ฐ์ฒด
1. button ๊ฐ์ฒด ์ถ๊ฐ
Library์์ Button์ ์ฐพ์ ์คํ ๋ฆฌ ๋ณด๋์ ์ถ๊ฐ
2. Aciton ํจ์ ์ ์ธ
button์ด touch ๋์์ ๋ ๋์ํ ์ฝ๋๋ฅผ ์์ฑํ๊ธฐ ์ํ Actionํจ์ ์ ์ธ
3. AlertController, AlertAction ์์ฑ
AlertController๋ฅผ ์ ์ธํด Alert์ ํ์๋ titile๊ณผ message ์ ์ธ
ok Action๊ณผ cancel Action ์์ฑ, Action์ handler์์ ํด๋น Action์ด ์ ํ๋์์ ๋ ๋์ํ ๊ตฌ๋ฌธ์ ์ ์ธ ๊ฐ๋ฅ
AlertController์ Action ์ถ๊ฐ ํ present ๋ฉ์๋ ์คํ
4. ์๋ฎฌ๋ ์ดํฐ ํ์ธ
Alert ๋ฒํผ ํด๋ฆญ ์ alert์ด ๋ํ๋จ
ok ๋ฒํผ์ ์ ํํ๋ฉด alert์ด ๊ทธ๋ฅ ์ข ๋ฃ๋์ง๋ง, cancel ๋ฒํผ์ ์ ํํ๋ฉด handler์์ ์ ์ธํ ๋๋ก background์ ์๊น์ด red๋ก ๋ฐ๋
Alert preferredStyle
- alert: ์ฐฝ์ ๋์์ฃผ๋ ๋๋
- actionSheet: ๋ฐ์์ ์๋ก ์ฌ๋ผ์ค๋ ๋๋
Alert addAction style
- default: ๊ธฐ๋ณธ ํํ
- destructive: ๋นจ๊ฐ์์ผ๋ก ๊ฐ์กฐ
- cancel: ์ทจ์ ์ก์ (actionSheet์ผ ๊ฒฝ์ฐ ๋ฐ๋ก ๋ฐ์ ํ์)
'๐ iOS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
MapView (0) | 2022.12.12 |
---|---|
WebView (0) | 2022.12.08 |
Picker View (0) | 2022.12.08 |
Date Picker (1) | 2022.10.05 |
UIImageView (0) | 2022.09.28 |