A photo picker that select photos from system albums
iOS 8.0, Swift 3.1
- Add
github "darkdong/PhotoPicker"
to your Cartfile - Run
carthage update --platform ios
- Add the framework to your project manually.
import PhotoPicker
in Swift file orimport <PhotoPicker/PhotoPicker.h>
in Objective-C file
Download and add sources to your project
let picker = PhotoPickerNavigationController.nc
present(picker, animated: true, completion: nil)
let picker = PhotoPickerNavigationController.nc
picker.config.rootTitle = "Root Title"
picker.config.mediaType = .image
present(picker, animated: true, completion: nil)
class ViewController: UIViewController {
func showPicker() {
let picker = PhotoPickerNavigationController.nc
picker.pickerDelegate = self
present(picker, animated: true, completion: nil)
}
}
extension ViewController: PhotoPickerDelegate {
func picker(_ picker: PhotoPickerNavigationController, didSelectAssets assets: [PHAsset]) {
//do what you want
//...
//dismiss picker
picker.dismiss(animated: true, completion: nil)
}
func picker(_ picker: PhotoPickerNavigationController, shouldSelectAsset: PHAsset, selectedAssets: [PHAsset]) -> Bool {
//limit number of selections
if selectedAssets.count >= 2 {
return false
}
return true
}
}
PhotoPicker is released under the MIT license. See LICENSE for details.