Re: iOS: Differentiating between 1 or 2 finger touches
Re: iOS: Differentiating between 1 or 2 finger touches
- Subject: Re: iOS: Differentiating between 1 or 2 finger touches
- From: Roland King <email@hidden>
- Date: Wed, 13 Jul 2011 11:33:10 +0800
Is the view multi touch enabled. Are you sure by the way you can't use a gesture recognizer for what you're doing? If you can, they make life a whole lot simpler.
On Jul 13, 2011, at 11:27, Nathan Sims <email@hidden> wrote:
> On Jul 12, 2011, at 5:28 PM, Greg Parker wrote:
>> On Jul 12, 2011, at 4:49 PM, Nathan Sims wrote:
>>> On Jul 12, 2011, at 4:46 PM, Fritz Anderson wrote:
>>>> On 12 Jul 2011, at 6:30 PM, Nathan Sims wrote:
>>>>> I have a, iOS 4.3.3 UIView that is touch-enabled. When my -touchesBegan:withEvent: method gets called, I can't figure out how to differentiate when the user touched the screen with one finger or with two. Either way, I receive this:
>>>>>
>>>>> <UITouchesEvent: 0x1796e0> timestamp: 423888 touches: {(
>>>>> <UITouch: 0x1d2ab0> phase: Began tap count: 1 window: <UIWindow: 0x197ac0; frame = (0 0; 768 1024); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x197c40>> view: <UIView: 0x1a1330; frame = (20 0; 748 1024); transform = [0, -1, 1, 0, 0, 0]; autoresize = W+H; layer = <CALayer: 0x1a13c0>> location in window: {572, 338} previous location in window: {572, 338} location in view: {686, 552} previous location in view: {686, 552}
>>>>> )}
>>>>>
>>>>> It tells me the 'tap count' but nowhere does it indicate if the user applied two fingers or just one. Instead of double-tapping or some other gesture, I need to make two fingers to mean 'quit the ongoing activity' to my program, whereas one finger means 'change value according to where the finger touched'.
>>>>>
>>>>> Am I looking in the wrong place for this touch information?
>>>>
>>>> The other parameter is there for a reason. It is a set of UITouches. Sets can be counted.
>>>
>>> I know, but [touches count] always returns 1, so I've resorted to [[event allTouches] count]; seems to work reliably.
>>> Thanks!
>>
>> The set of touches passed to -touchesBegan:withEvent: include only the newly-touched touches. Existing touches already in progress are not part of that set, but are part of -allTouches.
>>
>> Most likely, you're seeing the user's fingers not hit the screen simultaneously. Then you would get two calls to -touchesBegan:withEvent:, each with one new touch.
>
> If I put one finger down on the UIView, I get a -touchesBegan:withEvent: event. If I keep that finger down and put another down also I don't seem to get any event at all. Is there a way to know how many fingers are touching the UIView at any moment?
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden