小编MC.*_*MC.的帖子

PHPhotoLibrary.requestAuthorization()不会在iOS 9上触发授权提示

我有以下功能,显示一个带有两个不同选项的操作表.目前,唯一实施的选项是标题为"照片".正确显示操作表并调用正确的操作.我的问题是,在模拟器和实际设备上,我无法显示请求访问照片库的提示.

PHPhotoLibrary.authorizationStatus()返回.Denied并显示通知当前应用无法访问照片的模式: 在此输入图像描述

@IBAction func attachPhotoButtonTapped(sender: AnyObject) {
    let actionSheetController = UIAlertController(title: "Images", message: "Select image source...", preferredStyle: .ActionSheet)
    let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) {
        (action) in
        // ...
    }
    actionSheetController.addAction(cancelAction)

    let takePictureAction = UIAlertAction(title: "Camera", style: .Default) {
        (action) in
        // ...
    }
    actionSheetController.addAction(takePictureAction)

    let choosePictureAction = UIAlertAction(title: "Photos", style: .Default) {
        (action) in
        PHPhotoLibrary.requestAuthorization({(status:PHAuthorizationStatus) in
            switch status{
                case .Authorized:
                    dispatch_async(dispatch_get_main_queue(), {
                        print("Authorized")
                    })
                    break
                case .Denied:
                    dispatch_async(dispatch_get_main_queue(), {
                        print("Denied")
                    })
                    break
                default:
                    dispatch_async(dispatch_get_main_queue(), { …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch ios swift

8
推荐指数
1
解决办法
7499
查看次数

标签 统计

cocoa-touch ×1

ios ×1

swift ×1