小编Mar*_*ark的帖子

没有权限从照片库中选取照片

这是我的代码,可让用户选择个人资料照片:

早些时候,我只允许用户用相机拍照作为个人资料图片,但我决定更改它,以便用户现在可以从照片库中选择照片。

问题是我的用户能够访问照片库,而不会收到访问其照片库的请求警报。“某某应用程序想要访问您的照片库”。我有 Info.plist 用于照片库使用和照片库添加使用。此外,当我的应用程序在模拟器中运行时,当我进入“设置”然后进入“隐私”时,我会转到“照片”以查看我的应用程序是否具有访问权限,但那里没有任何内容提到我的应用程序可以访问照片库。

如果有人可以帮助我弄清楚我做错了什么以及如何让访问“照片库”的请求正常工作,我将不胜感激!谢谢。


class ProfileImageVC: UIViewController {

    @IBOutlet weak var AddAProfilePictureLabel: UILabel!
    
    @IBOutlet weak var ProfilePictureImageView: UIImageView!
    
    @IBOutlet weak var TapToChangeButton: UIButton!
    
    @IBOutlet var ErrorLabel: UILabel!
    
    @IBOutlet var FinishButton: UIButton!
    
    var ImagePicker:UIImagePickerController!
    

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.            

        let imageTap = UITapGestureRecognizer(target: self, action: #selector(openImagePicker))
        ProfilePictureImageView.isUserInteractionEnabled = true
        ProfilePictureImageView.addGestureRecognizer(imageTap)
        ProfilePictureImageView.layer.cornerRadius = ProfilePictureImageView.bounds.height / 2
        ProfilePictureImageView.clipsToBounds = true
        TapToChangeButton.addTarget(self, action: #selector(openImagePicker), for: .touchUpInside)

        //when user clicks they can choose a …
Run Code Online (Sandbox Code Playgroud)

ios swift

2
推荐指数
1
解决办法
2356
查看次数

标签 统计

ios ×1

swift ×1