there is no error, but when I test it on a real phone, even in a simulation, it only displays a lock image and "This application does not have access to your photos or videos that you can allow access in the privacy settings", but when I go to the settings , I could not find my application in the privacy settings. Where am I wrong?
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { if indexPath.row == 0 { if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary){ let imagePicker = UIImagePickerController() imagePicker.delegate = self imagePicker.allowsEditing = false let selectedSourceAction = UIAlertController(title: "What source do you want to access?", message: "", preferredStyle: UIAlertControllerStyle.ActionSheet) let fromPhotoLibrary = UIAlertAction(title: "Photo Library", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) -> Void in imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary self.presentViewController(imagePicker, animated: true, completion: nil) }) let fromCamera = UIAlertAction(title: "Camera", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) -> Void in imagePicker.sourceType = UIImagePickerControllerSourceType.Camera self.presentViewController(imagePicker, animated: true, completion: nil) }) let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil) selectedSourceAction.addAction(fromPhotoLibrary) selectedSourceAction.addAction(fromCamera) selectedSourceAction.addAction(cancelAction) self.presentViewController(selectedSourceAction, animated: true, completion: nil) } } func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) { imageView.image = info[UIImagePickerControllerOriginalImage] as? UIImage imageView.contentMode = UIViewContentMode.ScaleAspectFit imageView.clipsToBounds = true dismissViewControllerAnimated(true, completion: nil) }
source share