Combining a UILongPressGestureRecognizer with a UIPanGestureRecognizer

actually, you don’t have to combine gesture recognizers – you can do this solely with UILongPressGestureRecognizer… You enter StateBegan once your touch(es) have stayed within ‘allowableMovement’ for ‘minimumPressDuration’. You stay in your continuous longPressGesture as long as you don’t lift any of your fingers – so you can start moving your fingers and track the … Read more

Swift3 iOS – How to make UITapGestureRecognizer trigger function

From your code you are using swift 3.0 so change your selector syntax like this let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.tapBlurButton(_:))) and Your function like this func tapBlurButton(_ sender: UITapGestureRecognizer) { print(“Please Help!”) } Edit: Not idea that you are using button with tap gesture, instead of that use inbuilt method addTarget for button … Read more

UIGestureRecognizer blocks subview for handling touch events

I had a very similar problem and found my solution in this SO question. In summary, set yourself as the delegate for your UIGestureRecognizer and then check the targeted view before allowing your recognizer to process the touch. The relevant delegate method is: – (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

How to detect Swipe Gesture in iOS?

If You know how it works, but still need a quick example, here it is! (it will become handy at least for me, when I will need copy-paste example, without trying remembering it) UISwipeGestureRecognizer *mSwipeUpRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(doSomething)]; [mSwipeUpRecognizer setDirection:(UISwipeGestureRecognizerDirectionUp | UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionLeft | UISwipeGestureRecognizerDirectionRight)]; [[self view] addGestureRecognizer:mSwipeUpRecognizer]; and in .h file … Read more

UIGestureRecognizer on UIImageView

Check that userInteractionEnabled is YES on the UIImageView. Then you can add a gesture recognizer. imageView.userInteractionEnabled = YES; UIPinchGestureRecognizer *pgr = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)]; pgr.delegate = self; [imageView addGestureRecognizer:pgr]; [pgr release]; : : – (void)handlePinch:(UIPinchGestureRecognizer *)pinchGestureRecognizer { //handle pinch… }

UIGestureRecognizer and UITableViewCell issue

Instead of adding the gesture recognizer to the cell directly, you can add it to the tableview in viewDidLoad. In the didSwipe-Method you can determine the affected IndexPath and cell as follows: -(void)didSwipe:(UIGestureRecognizer *)gestureRecognizer { if (gestureRecognizer.state == UIGestureRecognizerStateEnded) { CGPoint swipeLocation = [gestureRecognizer locationInView:self.tableView]; NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:swipeLocation]; UITableViewCell* swipedCell = [self.tableView cellForRowAtIndexPath:swipedIndexPath]; … Read more

How to call gesture tap on UIView programmatically in swift

You need to initialize UITapGestureRecognizer with a target and action, like so: let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:))) myView.addGestureRecognizer(tap) Then, you should implement the handler, which will be called each time when a tap event occurs: @objc func handleTap(_ sender: UITapGestureRecognizer? = nil) { // handling code } So now calling your tap gesture … Read more

How do I implement the UITapGestureRecognizer into my application

This is a step by step guide on how to implement gesture recognizers in your class: Conform your class to UIGestureRecognizerDelegate protocol. Instantiate the gesture recognizer. For example, to instantiate a UITapGestureRecognizer, we will do: UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapFrom:)]; Here, action is the selector which will handle the gesture. Here, our selector … Read more