触摸屏图像基本上应该出现在触摸屏上但不起作用的地方。
-(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)];
}
答案 0 :(得分:0)
您无法调用UIImage,因为它只保存图像数据,您必须使用UIImageView然后才能工作。
所以请改用:
-(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)];
}
希望这会有所帮助:D