获取照片的权限或从iOS9中未显示的库中获取图像(Xcode 7beta,Swift2)

Dir*_*kLX 5 camera ios9 swift2

下面的代码显示了我访问图像lib的示例.无论我在哪里调用代码(视图),我都没有看到手机弹出的权限对话框,因此无法让我的应用程序访问相机或库.

此外,隐私设置也不显示我的应用程序.有什么想法吗?我疯了.

       let imgPicker = UIImagePickerController()
        imgPicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
        imgPicker.modalPresentationStyle = UIModalPresentationStyle.Popover
        self.presentViewController(imgPicker, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

我试过的另一种方式

            if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) {
                let imagePicker:UIImagePickerController = self.imagePickerController

                imagePicker.allowsEditing       =   true
                imagePicker.sourceType          =   UIImagePickerControllerSourceType.Camera
                imagePicker.cameraCaptureMode   =   UIImagePickerControllerCameraCaptureMode.Photo
                imagePicker.cameraDevice        =   UIImagePickerControllerCameraDevice.Rear
                imagePicker.showsCameraControls =   true
                imagePicker.navigationBarHidden =   true
                imagePicker.toolbarHidden       =   true
                imagePicker.delegate = self

            self.presentViewController(imagePicker, animated: true, completion: nil)
            }
Run Code Online (Sandbox Code Playgroud)

Dir*_*kLX 0

显然这似乎是 iOS9 的问题。由于某种原因,权限访问对话框不会弹出。我已经使用相同的代码在iOS8上成功进行了测试。