SJImagePickerViewController
Installation
CocoaPods
- Add
pod 'SJImagePickerController'
to your Podfile. - Run
pod install
orpod update
. - Import SJImagePickerController.
Swift Package Manager (SPM)
let package = Package( … dependencies: [ .package(url: "https://github.com/SJ-Lyran/SJImagePickerViewController.git", from: "1.2.2"), ], )
Manually
- Download all the files in the
SJImagePickerController
subdirectory. - Add the source files to your Xcode project.
- Add
NSPhotoLibraryUsageDescription
info.plist
insert
<key>PHPhotoLibraryPreventAutomaticLimitedAccessAlert</key>
<true/>
Usage
SJImagePickerController works as a normal controller, just instantiate it and present it.
let imagePicker = SJImagePickerController(delegate: self)
present(imagePicker, animated: true, completion: nil)
SJImagePickerController has two delegate methods that will inform you what the users are up to:
func imagePickerController(_ picker: SJImagePickerController, didFinishPickingMediaWithInfo info: [SJImagePickerController.InfoKey : Any])
func imagePickerControllerDidCancel(_ picker: SJImagePickerController)
SJImagePickerController supports limiting the amount of images that can be selected, it defaults to 9
let imagePicker = SJImagePickerController(delegate: self)
imagePicker.maximumSelectedPhotoCount = 9