如何让用户选择多个图像,然后在swift中将它们作为数组上传?或者,任何人都可以建议一个记录良好的swift库,允许用户选择多个图像吗?
我的代码只允许我一次选择一张图片:
import UIKit
class SubmitPhoto: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate{
@IBOutlet weak var imageView: UIImageView!
@IBAction func pickGalleryBtn(sender: AnyObject) {
imagePicker.allowsEditing = false
imagePicker.sourceType = .PhotoLibrary
presentViewController(imagePicker, animated: true, completion: nil)
}
@IBOutlet weak var commentField: UITextView!
@IBAction func submitBtn(sender: AnyObject) {
}
let imagePicker = UIImagePickerController()
var slctdImage: [String] = []
override func viewDidLoad() {
super.viewDidLoad()
imagePicker.delegate = self
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
imageView.contentMode = .ScaleAspectFit
imageView.image = pickedImage
uploadImage(pickedImage)
}
dismissViewControllerAnimated(true, completion: nil)
}
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
dismissViewControllerAnimated(true, completion: nil)
}
func uploadImage(image:UIImage){
}
}