Finger gesture

As far as I noticed, the Tap gesture cancels the event when the finger moves. Here is the screen shot from the event handling guide:

enter image description here

I have already done some tests with the following code. No, it cancels ...

http://i.hizliresim.com/ogZVjR.png

    @IBAction func dosomething(sender: UITapGestureRecognizer) {
         //called by gesture recognizer   
        }
        @IBOutlet var red: UIView!
        @IBOutlet var green: UIView!

        @IBOutlet var yellow: UIView!

        @IBOutlet var white: UIView!

        //setting delegate when outlet get set.
        @IBOutlet var tapGesture: UITapGestureRecognizer! { didSet { outlet.delegate = self
            }}
        //delegate func shouldReceiveTouch
        func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
            if touch.view == red {
                println("ez")
                return true
            }else if touch.view == green{
                println("bp")
                return false
            }else { view.backgroundColor = UIColor.clearColor()
                return true}
        }

So, if I am right when the called touchesMoved:, there tapGestureRecognizershould be a failure, but according to the figure, it is not. What am I missing here?

+4
source share
1 answer

When a user selects or drags his finger across the screen in the iPhone application, two things happen:

  • View gets an object UITouch
  • A UIGestureRecognizer UITouch , ( /, /, ..)

A UIGestureRecognizer , , . IPhone , , (t) > t20 > .

, UIGestureRecognizer " ", , . 1-6. , , . . , . - , UIGestureRecognizer, UIPanGestureRecognizer, UILongPressGestureRecognizer, UISwipeGestureRecognizer ..

, iOS Single View:

  • ViewController.swift.
  • ViewController UIViewController.
  • UIGestureRecognizerDelegate.
  • UITapGestureRecognizer UITouch .
  • UIGestureRecognizer delegate UIViewController self.
  • , , println touchesBegan:withEvent:, touchesMoved:withEvent:, touchesEnded:withEvent touchesCancelled:withEvent.

, iOS Developer Library .

+2

All Articles