there is no error but when i test it on real phone, even in the simulation, it only display a lock image and "This app does not have access to your photos or videos you can enable access in Privacy settings" but when i turn to setting I couldn't find my app in privacy setting. Where did i go 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)
}
Such bug may happen on IOS 9 when your application's Info.plist file contains a key: "CFBundleDisplayName" with empty string value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With