enter image description here我正在约会应用程序。 因此用户需要在配置文件中更新其图像。 在个人档案部分, 有小3图像意见。 ,如果他们想要添加图像到每个图像视图,他们应该通过UIimagepicker更新每个图像视图。 但我知道我只能在UIImagepikerControllerDelegate协议中只使用一个函数。如何添加多个图像视图和每个图像视图可以执行图像选择?
我该怎么做?下面
是我的失败代码
进口的UIKit
类RegisterPicture:UIViewController中,UIImagePickerControllerDelegate,UINavigationControllerDelegate {
@IBAction func pick1(sender: AnyObject) {
let picker1 = UIImagePickerController()
picker1.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum
picker1.allowsEditing = true
picker1.delegate = self
self.presentViewController(picker1, animated: false, completion: nil)
}
@IBAction func pick2(sender: AnyObject) {
let picker2 = UIImagePickerController()
picker2.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum
picker2.allowsEditing = true
picker2.delegate = self
self.presentViewController(picker2, animated: false, completion: nil)
}
@IBAction func pick3(sender: AnyObject) {
let picker = UIImagePickerController()
picker.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum
picker.allowsEditing = true
picker.delegate = self
self.presentViewController(picker, animated: false, completion: nil)
}
@IBOutlet var picture1: UIImageView!
@IBOutlet var picture2: UIImageView!
@IBOutlet var picture3: UIImageView!
func imagePickerController(picker1: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
picker1.dismissViewControllerAnimated(false, completion : nil)
}
func imagePickerController(picker2: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
picker2.dismissViewControllerAnimated(false, completion : nil)
self.picture2.image = info[UIImagePickerControllerOriginalImage] as? UIImage
}
func imagePickerController(picker3: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
picker3.dismissViewControllerAnimated(false, completion : nil)
self.picture3.image = info[UIImagePickerControllerOriginalImage] as? UIImage
}
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
picker.dismissViewControllerAnimated(false, completion:nil)
}
func imagePickerControllerDidCancel(picker2: UIImagePickerController) {
picker2.dismissViewControllerAnimated(false, completion:nil)
}
func imagePickerControllerDidCancel(picker3: UIImagePickerController) {
picker3.dismissViewControllerAnimated(false, completion:nil)
}
你可以检查我的代码? – kimpro
你必须使用这个功能,我已经提到没有这个你不能做你想要的功能,据我所知,每个imageview使用标签 – 2016-05-13 10:34:20