๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐ŸŽ iOS/UI

[iOS] Swift ์‚ฌ์ง„ ํ—ˆ๊ฐ€๋ฐ›์€ ์ƒํƒœ์•Œ๊ธฐ ๋ฐ ์„ธํŒ…์œผ๋กœ ์ธ๋„ํ•˜๊ธฐ

by Fomagran ๐Ÿ’ป 2020. 3. 23.
728x90
๋ฐ˜์‘ํ˜•

์šฐ์„  ์ฒดํฌํฌํ† ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌํผ๋ฏธ์…˜ ๋ฉ”์†Œ๋“œ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ๊ณ 

๊ฐ ์ƒํƒœ์— ๋”ฐ๋ผ ํ•ด์•ผํ•  ์ผ์„ ์ •ํ•ด์ค€๋‹ค

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 func checkPhotoLibraryPermission() {
           let status = PHPhotoLibrary.authorizationStatus()
           switch status {
           case .authorized:
            self.testlabel.text = "ํ—ˆ๋ฝ"
           case .denied, .restricted :
          self.testlabel.text = "์•„์ง"
           case .notDetermined:
              self.testlabel.text = "๊ฒฐ์ •๋ชปํ•จ"
               PHPhotoLibrary.requestAuthorization { status in
                   switch status {
                   case .authorized:
                   self.testlabel.text = "ํ—ˆ๋ฝ"
                   case .denied, .restricted:
                  self.testlabel.text = "์•„์ง"
                   case .notDetermined:
                  self.testlabel.text = "๊ฒฐ์ •๋ชปํ•จ"
                   }
               }
           }
       }
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter

๊ทธ ๋‹ค์Œ ๋ทฐ๋””๋“œ๋กœ๋“œ์— ๋ฉ”์†Œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ๊ณ 

์„ธํŒ…์œผ๋กœ ์ธ๋„ํ•ด์ฃผ๋Š” ๋ฐฉ๋ฒ•์€ UIApplication.openSettingsURLString์„ ์ด์šฉํ•ด์ค˜์„œ settingํ™”๋ฉด์œผ๋กœ ๊ฐ€๊ฒŒํ•œ๋‹ค.

1
2
3
4
 if let url = URL(string: UIApplication.openSettingsURLString) {
            if UIApplication.shared.canOpenURL(url) {
            }
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter

728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€