Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
- if indexPath.row == 0 {
- handleSelectProfileImageView()
- } else {
- let cell = collectionView.cellForItem(at: indexPath) as ?
- CustomUICollectionViewCell
- let currentPhoto = gallery[indexPath.row - 1]
- let galleryPreview = INSPhotosViewController(photos: gallery, initialPhoto: currentPhoto, referenceView: cell)
- galleryPreview.referenceViewForPhotoWhenDismissingHandler = {
- [weak self] photo in
- if let index = self ? .gallery.index(where: {
- $0 === photo
- }) {
- let indexPath = NSIndexPath(item: index, section: 0)
- return collectionView.cellForItem(at: indexPath as IndexPath) as ? CustomUICollectionViewCell
- }
- return nil
- }
- present(galleryPreview, animated: true, completion: nil)
- }
- }
- @objc func handleSelectProfileImageView() {
- let picker = UIImagePickerController()
- picker.delegate = self
- picker.allowsEditing = false
- present(picker, animated: true, completion: nil)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement