我有一张个人资料图片,也可以作为一个按钮,当用户点击图片选择器显示的图片时,他们可以选择他们想要用作个人资料图片的图片,但SELECT m.username FROM members m, (SELECT sponsor, COUNT(sponsor) FROM members GROUP BY sponsor HAVING COUNT(sponsor) >= 5) c WHERE m.username != c.sponsor
不是被调用,并且没有调用Parse db映像文件。为什么会发生这种情况,我该如何解决?
imagePickerController
答案 0 :(得分:4)
在swift 2.0
及以后,如果您使用任何代理UIImagePickerControllerDelegate
,则需要强制实现委托方法,否则不要在您的viewcontroller中使用或不添加,这是概念,现在按照这个
一些例子
<强>步骤1 强>
在视图控制器中添加UIImagePickerControllerDelegate, UINavigationControllerDelegate
class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@IBOutlet var imageView: UIImageView!
let imagePicker = UIImagePickerController()
<强>步骤-2 强>
override func viewDidLoad() {
super.viewDidLoad()
imagePicker.delegate = self // Its Manotary
}
<强>步骤-3 强>
// Present the Image picker controller
@IBAction func loadImageButtonTapped(sender: UIButton) {
imagePicker.allowsEditing = false
imagePicker.sourceType = .PhotoLibrary
presentViewController(imagePicker, animated: true, completion: nil)
}
<强>步骤4 强>
// call the delegate method for pick the image
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
imageView.contentMode = .ScaleAspectFit
imageView.image = pickedImage
}
dismissViewControllerAnimated(true, completion: nil)
}
<强>步骤5 强>
// finally dismiss the Imagepicker controller
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
dismissViewControllerAnimated(true, completion: nil)
}