1

I'd like to create my own gesture recognizer, and to create a kind of pinch & zoom I'd like to get position of all fingers at any moment.

Right now I'm able to track a finger with :

var countTouch:[Int] = []
var rawPoints:[Int] = []

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
    if(rawPoints[rawPoints.count-2] != Int(location.x) && rawPoints[rawPoints.count-1] != Int(location.y)) {
        rawPoints.append(Int(location.x))
        rawPoints.append(Int(location.y))
    }
}

And to know how many fingers are touching the screen at the moment with :

    super.touchesMoved(touches, 
    countTouch.append((event?.allTouches?.count)!)

But I don't know where all the data about position of the other fingers are going.

Can someone help on this please ?

Hawkydoky
  • 194
  • 1
  • 15
  • The `Set` includes a `UITouch` for each finger. Each `UITouch` has a `location(in:)` method to get it's location in a view. it's unclear what part you're having trouble with. – Rob Napier Jun 28 '17 at 14:22
  • @RobNapier My trouble is to get the position of each finger. How to access it ? Is it an array where I just have to do [finger#x][x position] ? Or something else. I don't understand how it works for multiple touches. Is it clearer ? – Hawkydoky Jun 28 '17 at 14:37
  • 1
    This https://stackoverflow.com/a/39823992/7113238 might be helpful for you. – Lawliet Jun 28 '17 at 14:38
  • Ok, it looks like it's working. Make an answer with the code and a link to the previous answer, and I'll mark you as the correct answer :) Thank you for your answer. – Hawkydoky Jun 29 '17 at 07:16

0 Answers0