Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  2. if indexPath.row == 0 {
  3. handleSelectProfileImageView()
  4. } else {
  5. let cell = collectionView.cellForItem(at: indexPath) as ?
  6. CustomUICollectionViewCell
  7. let currentPhoto = gallery[indexPath.row - 1]
  8. let galleryPreview = INSPhotosViewController(photos: gallery, initialPhoto: currentPhoto, referenceView: cell)
  9. galleryPreview.referenceViewForPhotoWhenDismissingHandler = {
  10. [weak self] photo in
  11. if let index = self ? .gallery.index(where: {
  12. $0 === photo
  13. }) {
  14. let indexPath = NSIndexPath(item: index, section: 0)
  15. return collectionView.cellForItem(at: indexPath as IndexPath) as ? CustomUICollectionViewCell
  16. }
  17. return nil
  18. }
  19. present(galleryPreview, animated: true, completion: nil)
  20. }
  21. }
  22.  
  23. @objc func handleSelectProfileImageView() {
  24. let picker = UIImagePickerController()
  25. picker.delegate = self
  26. picker.allowsEditing = false
  27. present(picker, animated: true, completion: nil)
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement