I'm making dating app. as you know, users need to register multiple pictures in dating app.
so i got how to use 1 image picker in one view.
but i don't know how to add multiple image picker.
i know i can only use only one
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
}
and
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
picker.dismissViewControllerAnimated(false, completion:nil)
}
so i cant find solution for multiple imagepicker view.
my failed code is below.
import UIKit
class 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)
}
@IBOutlet var picture1: UIImageView!
@IBOutlet var picture2: UIImageView!
func imagePickerController(picker1: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
picker1.dismissViewControllerAnimated(false, completion : nil)
self.picture1.image = info[UIImagePickerControllerOriginalImage] as? UIImage
}
func imagePickerController(picker2: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
picker2.dismissViewControllerAnimated(false, completion : nil)
self.picture2.image = info[UIImagePickerControllerOriginalImage] as? UIImage
}
func imagePickerControllerDidCancel(picker1: UIImagePickerController) {
picker1.dismissViewControllerAnimated(false, completion:nil)
}
func imagePickerControllerDidCancel(picker2: UIImagePickerController) {
picker2.dismissViewControllerAnimated(false, completion:nil)
}
}