这是我的代码。我已经实现了UIImagePicker
,但在运行时它不会向我显示允许访问模拟器中的图库的对话框
@IBOutlet var uploadImage: UIImageView!
@IBAction func upldImageBtn(sender: UIButton) {
imagePicker.allowsEditing = false
imagePicker.sourceType = .PhotoLibrary
presentViewController(imagePicker, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage{
uploadImage.contentMode = .ScaleAspectFill
uploadImage.image = pickedImage
uploadImage.layer.borderWidth = 0.5
uploadImage.layer.masksToBounds = false
uploadImage.layer.cornerRadius = uploadImage.frame.size.height/2
uploadImage.clipsToBounds = true
}
dismissViewControllerAnimated(true, completion: nil)
}
最佳答案
尝试重置模拟器。
该选项在菜单-> iOS模拟器->重置内容和设置...中可用。
如果这样做没有帮助,请发布您所看到的运行时错误的详细信息。
关于ios - UIImagePicker给出运行时错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33737392/