首页 > 解决方案 > 如果快速拒绝访问照片库的权限,如何直接进入设置

问题描述

class func checkPhotoLibraryPermission() {
        // TODO: @Umer Complete this process as discussed
        let photoAuthorizationStatus = PHPhotoLibrary.authorizationStatus()
        switch photoAuthorizationStatus {
        case .authorized:
            print("Access is granted by user")
        case .notDetermined:
            PHPhotoLibrary.requestAuthorization({
                (newStatus) in
                print("status is \(newStatus)")
                if newStatus ==  PHAuthorizationStatus.authorized {
                    /* do stuff here */
                    print("success")
                }
                else {
                }
            })
            print("It is not determined until now")
        case .restricted:
            print("User do not have access to photo album.")
        case .denied:
            print("User has denied the permission.")
        }
    }

in case .denied 如果我们第一次访问照片库的访问权限被询问给用户,如果用户不允许权限,下次当用户尝试访问照片库时,它直接进入用户可以手动设置权限的设置。

标签: iosiphoneswift3

解决方案


推荐阅读