-1

Basically touch screen image should appear where touched but doesn't work.

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];
    UIImage *image = [[UIImage alloc]initWithContentsOfFile:@"BluePin.png"];
    [image drawAtPoint:CGPointMake(location.x, location.y)];
}
Aptlymade
  • 1
  • 1
  • 6

1 Answers1

0

You cant call on a UIImage as it only holds the image data, you have to use the UIImageView instead and then is should work.

So use this instead:

-(void) touchBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
UImageView *imageView = [[UIImageView alloc] init];
UIImage *image = [[UIImage imageNamed:@"BluePin.png"];
imageView.image = image;
[imageView drawAtPoint:CGPointMake(location.x, location.y)];
}

Hope this helps :D

Philip Laine
  • 458
  • 3
  • 17