ImageSlideshow icon indicating copy to clipboard operation
ImageSlideshow copied to clipboard

Feature Request : Custom Double Tap Callback

Open adamfraser opened this issue 8 years ago • 4 comments

Is it possible to add a double tap gesture to ImageSlideShow? I'm trying to implement functionality similar to Instagram where a user can double tap an image to "like" it. The issue is that ImageSlideShowItem already implements a double tap gesture to perform the zoom actions.

Would be great if you could pass a custom double tap for ImageSlideShow and then fallback to the tap to zoom when in full screen mode (or even just override default, pinch to zoom would still be avaliable)

adamfraser avatar Oct 11 '16 21:10 adamfraser

+1 on this

decoyfox avatar Jan 05 '17 21:01 decoyfox

Big +1 on this

CalvHobbes avatar May 29 '19 15:05 CalvHobbes

Another Big +1 on this

nastasiupta avatar Feb 11 '20 10:02 nastasiupta

Until this is officially added, you can workaround the incumbent double tap gesture recognizer, with something like:

let slideshowSubviews = imageSlideshowView.slideshowItems.compactMap({ $0.subviews }).reduce([], +)
slideshowSubviews.forEach { subview in
     if let tapGestures = subview.gestureRecognizers?.filter({ $0 is UITapGestureRecognizer }) as? [UITapGestureRecognizer] {
          let doubleTapGestures = tapGestures.filter { $0.numberOfTapsRequired == 2 }
          doubleTapGestures.forEach { subview.removeGestureRecognizer($0) }
     }
}
		
let doubleTap = UITapGestureRecognizer(target: self, action: #selector(handleDoubleTap))
doubleTap.numberOfTapsRequired = 2
doubleTap.numberOfTouchesRequired = 1
imageSlideshowView.addGestureRecognizer(doubleTap)

Disclosure: Not thoroughly tested - this could break other things 😛

edwardbeecroft avatar Sep 06 '20 16:09 edwardbeecroft