add access for selected photos permission

This commit is contained in:
ryanzhao 2022-05-25 14:57:05 +10:00
parent b54de30d5c
commit 113a931645
1 changed files with 13 additions and 0 deletions

View File

@ -92,6 +92,19 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
selectionPanGesture.delegate = self
self.selectionPanGesture = selectionPanGesture
collectionView.addGestureRecognizer(selectionPanGesture)
if #available(iOS 14, *) {
if PHPhotoLibrary.authorizationStatus(for: .readWrite) == .limited {
let addSeletedPhotoButton = UIBarButtonItem.init(barButtonSystemItem: .add, target: self, action: #selector(addSelectedPhoto))
self.navigationItem.rightBarButtonItem = addSeletedPhotoButton
}
}
}
@objc func addSelectedPhoto(_ sender: Any) {
if #available(iOS 14, *) {
PHPhotoLibrary.shared().presentLimitedLibraryPicker(from: self)
}
}
var selectionPanGesture: UIPanGestureRecognizer?