iOS4.2:TouchBegan每次感应触摸不会绘制多个圆圈

时间:2011-01-15 08:45:51

标签: cocoa-touch touch multi-touch

快速提问(这对大多数人来说可能是明智的):))

下面的代码应该为每次识别的触摸画一个圆圈但是虽然感觉到的触摸多于一次但是一次只会绘制一个圆圈。

任何人都可以看到任何明显的问题吗?

此方法位于XYZViewControler.m类中。 TouchPoint.m是定义圆圈的类。

感谢您的帮助和重定向。

克里斯


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

 NSSet * allTouches = [event allTouches];  // get all events

 for (UITouch * touch in touches) {

  TouchPoint * touchPoint = [[TouchPoint alloc] initWithFrame:CGRectMake(0, 0, circleWidth, circleWidth)];

  touchPoint.center = [touch locationInView:[self view]]; 
  touchPoint.color = [UIColor redColor];
  touchPoint.backgroundColor = [UIColor whiteColor];

  [[self view] addSubview: touchPoint];
  [touchPoint release];

  CFDictionarySetValue(touchMap, touch , touchPoint); 
 }

 [[self view] setNeedsDisplay];
    }

1 个答案:

答案 0 :(得分:1)

代码如果罚款!必须为视图启用多点触控才能使其正常工作!

@property(nonatomic, getter=isMultipleTouchEnabled) BOOL multipleTouchEnabled
相关问题