You can do this with just an UIPanGestureRecognizer
or an UILongPressGestureRecognizer
. In the gesture handling method, check the state
property of the recognizer, and show your image when it's UIGestureRecognizerStateEnded
(i.e. when the user lifts the finger from the screen). E.g.:
- (void)handleGesture:(UILongPressGestureRecognizer *)recognizer {
if(recognizer.state == UIGestureRecognizerStateEnded) {
// gesture ended: show the image
}
else if(recognizerState == UIGestureRecognizerStateBegan) {
// this code runs when the gesture is started.
}
else if(recognizerState == UIGestureRecognizerStateChanged) {
// gesture is in progress
}
}