A controller to pick saved images.
// In a controller
let picker = SWImagePickerController()
picker.delegate = self // conforms to SWImagePickerControllerDelegate
picker.allowsMultipleSelection = false // or picker.maxSelectionCount = 1
picker.maxSelectionCount = yourNumber // default is 5
navigationController?.pushViewController(picker, animated: true)
let nc = UINavigationController(rootViewController: picker)
present(nc, animated: true, completion: nil)
func imagePickerController(_ picker: SWImagePickerController, didFinishPickingImageWithInfos infos: [[String : AnyObject]]) {
for dict in infos {
let image = dict[SWImagePickerControllerImage] as! UIImage
let assetLocalID = dict[SWImagePickerControllerAssetLocalIdentifier] as! String
// Do someting with image or asset local id
}
}
// Optional
func imagePickerControllerDidCancel(_ picker: SWImagePickerController) {}