Drawing a UIImageView at position of user tap
This is the 2nd time I have asked this. How do I draw an image at the location of the user's tap every time the user taps the screen?
Could you please leave a sample project or code because I am new to iPhone programm开发者_运维问答ing and have a hard time understanding certain methods etc. Thanks, Tate
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
UIImageView * anImageView = [[UIImageView alloc] initWithImage:anImage];
[anImageView setCenter:[touch locationInView:self.view]];
[self.view addSubview:anImageView];
[anImageView release];
}
In the future, read the documentation or use Google.
精彩评论