Swift 3.0
Info.plistにNSPhotoLibraryUsageDescriptionを追加します
//
// ViewController.swift
// phptokit001
//
// Copyright © 2016年 FaBo, Inc. All rights reserved.
//
import UIKit
import Photos
class ViewController: UIViewController {
override func viewDidLoad() {
// ユーザーに許可を促す.
PHPhotoLibrary.requestAuthorization({ status in
switch status {
case .authorized:
print("Authorized")
case .denied:
print("Denied")
case .notDetermined:
print("NotDetermined")
case .restricted:
print("Restricted")
}
})
}
}
Swift 2.3
//
// ViewController.swift
// phptokit001
//
// Copyright © 2016年 FaBo, Inc. All rights reserved.
//
import UIKit
import Photos
class ViewController: UIViewController {
override func viewDidLoad() {
// ユーザーに許可を促す.
PHPhotoLibrary.requestAuthorization({ status in
switch status {
case .Authorized:
print("Authorized")
case .Denied:
print("Denied")
case .NotDetermined:
print("NotDetermined")
case .Restricted:
print("Restricted")
}
})
}
}
2.xと3.xの差分
enum列挙体PHAuthorizationStatusのイニシャルが小文字に変更
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.