Sunday, April 3, 2011

Multi-touch is not working in the iphone app I'm building

I have the following code:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {


NSUInteger touchCount = 0;
// Enumerates through all touch objects
for (UITouch *touchb in touches){
    touchCount++;
}


// When multiple touches, report the number of touches. 
if (touchCount > 1) {
 lblStatustouch.text = [NSString stringWithFormat:@"Tracking %d touches", touchCount];
} else {
 lblStatustouch.text = [NSString stringWithFormat:@"Tracking 1 touch", touchCount];
}

When I run it, it never detects more than one touch. Is there some setting that may prevent my app from taking multiple touches? Or am I missing something here?

From stackoverflow
  • You need to enable "Multiple Touch" on your View in InterfaceBuilder

    alt text

    or if you have created the View in code it's set with

    [theView setMultipleTouchEnabled:YES];
    
    Bryan Cimo : Thank You, I created the view in code and was going nuts trying to figure it out. I did that and now it's working great!
    Kristopher Johnson : Bryan, if this is the right answer, you should "accept" it by clicking the little green checkmark to the left of the answer.
  • Also know that you will only get multiple touches in touchesMoved if both fingers are moving at the same time. If you have a single finger fixed on the screen, and move a second finger around, the phone will only report the finger that is moving.

0 comments:

Post a Comment