Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Rather than using allTouches on the UIEvent, you should use the <em>touches</em> set that you get in the call to your <code>UIView</code>'s (or other <code>UIResponder</code>'s) <code>touchesEnded:withEvent:</code> method. This ensures that you don't get touches that belong to other views.</p> <p>Since the iPhone is a multi-touch device, the set contains all the touches that are associated with that event. In other words, if the user is touching the screen with two fingers, there should be two <code>UITouch</code> objects in the set, etc.</p> <p>This means that the set does <strong>not</strong> contain all the points traversed since a touch began until it ended. To track that, you have to save the start point and time in <code>touchesBegan:withEvent:</code>, and then when the touch ends you calculate the speed based on that.</p> <p>Note that if the set contains several points (which means the user is touching the screen with several fingers), you have to try to keep track of which <code>UITouch</code> object corresponds to which finger. You will want to do this in <code>touchesMoved:withEvent:</code>.</p> <p>Since you get the touches in a set, you can't use an index or some key value to keep track of the touches you are interested in. I believe that the recommended way of doing this is to just assume that the touch that is closest to the point you saved on the previous event comes from the same finger. If you want to be more exact you can also use the UITouch's <code>previousLocationInView:</code> method.</p> <p>If you're lazy, you can also simply do <code>[[touches allObjects] objectAtIndex:0]</code> and hope that this will give you the right touch (ie the one originating from the same finger) on each event. This actually often works, but I don't think you should use it in production code, especially not if you're trying to create an app with multi-touch functionality.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload