iOS4.2: TouchBegan does not draw more then one circle per sensed touch

Posted by Christian on Stack Overflow See other posts from Stack Overflow or by Christian
Published on 2011-01-15T08:45:50Z Indexed on 2011/01/15 8:53 UTC
Read the original article Hit count: 312

Filed under:
|
|

Hi all,

quick question (which might be a no-brainer for most here) :)

My code below should draw a circle for every time touch that is recognised but although more than ones touches are sensed only one circle will drawn up at a time.

Can anyone see any obvious issues?

This method sits in the XYZViewControler.m class. TouchPoint.m is the class that defines the circle.

Thanks a bundle for your help and redirects.

Chris


- (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];
    }

© Stack Overflow or respective owner

Related posts about cocoa-touch

Related posts about touch