Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

potash

macrumors newbie
Original poster
Jun 16, 2011
8
0
Hi, I have subclassed a view and implemented its touchesBegan() method to detect a touch event. I'm able to detect multi-touch event in this way. But I couldn't detect a sequential touch. That is, when I press the screen (I get an event for the first touch) without releasing the first finger, and follow up by pressing the screen again in another location with a second finger, the second touch did not generate an event. Is there a way to get an event for the second touch?
 
Last edited:
It's not really a tap gesture I'm trying to detect. My situation is I have the movement buttons on one side, and actions buttons on the other side. The movement button is pressed and hold to move the character, once button is released the movement stop. While there is movement, an action button can be pressed. Both type of buttons work independently of each other.
 
I made a really simple program that counts how many touches are on the screen a while back:

Code:
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.userInteractionEnabled = YES;
    self.view.multipleTouchEnabled = YES;
}
     
- (BOOL)canBecomeFirstResponder
{
    return YES;
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    touchCounterLabel.text = [NSString stringWithFormat:@"%d", ([touchCounterLabel.text intValue] + [touches count])];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    touchCounterLabel.text = [NSString stringWithFormat:@"%d", ([touchCounterLabel.text intValue] - [touches count])];
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    touchCounterLabel.text = [NSString stringWithFormat:@"%d", ([touchCounterLabel.text intValue] - [touches count])];
}

This works perfectly... so if you modify what I've posted to actually receive the position of the touches, it should be able to tell whether each button is being pressed or not.

Oh, potential issue your code has now that I think of it, what if you set the exclusiveTouch property of the view to NO? I know the documentation says the default value is already NO, but it's been wrong before.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.