1. ๋ ์ด์์ ๊ตฌ์ฑ
ViewController์ ์ด๋ฏธ์ง๋ฅผ ๋ํ๋ผ ImageView์ "์ฌ์ง ์ดฌ์ํ๊ธฐ", "์ฌ์ง ๋ถ๋ฌ์ค๊ธฐ" Button 2๊ฐ๋ฅผ ์ถ๊ฐํ์ฌ ๋ ์ด์์์ ๊ตฌ์ฑํ๋ค.
2. ์์๋ ๋ณ์, ์ก์ ํจ์ ์ถ๊ฐ
ImageView์ ๋ํ ์์๋ ๋ณ์์ ๋ ๋ฒํผ์ ๋ํ ์ก์ ํจ์๋ฅผ ์ถ๊ฐํ๋ค.
3. ํค๋ ํ์ผ๊ณผ ๋ธ๋ฆฌ๊ฒ์ดํธ ํ๋กํ ์ฝ ์ถ๊ฐ, ๋ณ์ ์ ์ธ
๋ฏธ๋์ด ํ์ ์ด ์ ์๋ ํค๋ํ์ผ "MobileCoreServices"์ Image Picker Controller๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํ ๋ธ๋ฆฌ๊ฒ์ดํธ ํ๋กํ ์ฝ์ ์ ์ธํ๋ค.
UIImagePickerController์ ์ธ์คํด์ค ๋ณ์์ธ imgPicker๋ฅผ ์์ฑํ๋ค.
4. ๊ธฐ๋ฅ ์ฝ๋ ๊ตฌํ
์ฌ์ง์ดฌ์ ๋ฒํผ์ด ํด๋ฆญ๋๋ฉด, imagePicker์ ์์ค ํ์ ์ camera, ๋ฏธ๋์ด ํ์ ์ public.image๋ก ์ค์ ํ ํ, ํ์ฌ View Controller๋ฅผ imagePicker๋ก ๋์ฒดํ๋ค.
์ฌ์ง ๋ถ๋ฌ์ค๊ธฐ ๋ฒํผ์ ํด๋ฆญํ๋ฉด, imagePicker์ ์์ค ํ์ ์ photoLibrary๋ก ํ ํ ์ฌ์ง ์ดฌ์๊ณผ ๋์ผํ ๋์์ ์ํํ๋ค.
imagePicker์ ์ฌ์ง ์ ํ์ด ๋๋ฌ๋ค๋ฉด, ์ ํํ ์ฌ์ง์ ๊ฐ์ ธ์ imageView์ ๋ณด์ฌ์ค๋ค. ๊ทธ๋ฆฌ๊ณ ํ์ฌ์ View Controller(Image Picker ํ๋ฉด)์ ์ ๊ฑฐํ ํ ์ด๊ธฐ View๋ฅผ ๋ณด์ฌ์ค๋ค.
์ทจ์๋ฒํผ์ ๋๋ฅธ ๊ฒฝ์ฐ, ํ์ฌ์ View Controller(Image Picker ํ๋ฉด)์ ์ ๊ฑฐํ ํ ์ด๊ธฐ View๋ฅผ ๋ณด์ฌ์ค๋ค.
5. ์๋ฎฌ๋ ์ดํฐ ํ์ธ
์๋ฎฌ๋ ์ดํฐ์์ ์ฌ์ง ์ดฌ์์ ํ๊ธฐ ์ํด์๋ ๊ฐ๋ฐ์ ํ๋ก๊ทธ๋จ์ ๋ฑ๋ก์ ํด์ผ ํ๋ค.
'๐ iOS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Tap Touch (0) | 2023.01.11 |
---|---|
Core Graphics (0) | 2023.01.10 |
Movie Player (0) | 2023.01.04 |
AVAudioPlayer (0) | 2023.01.03 |
Table View Controller (0) | 2022.12.28 |