in my application, I have a view named mainvie - when the application runs, mainview is loaded which loads a background image onto the screen ( code below) ring_large.jpg has been added as a file.
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed:@"rink_large.jpg"];
CGPoint imagepoint = CGPointMake(10,0);
[image drawAtPoint:imagepoint];
}
This works fine, it is when I am trying to draw another image on top of this that I am having issues. Elsewhere (file named mainviewcontroller.m) - On a touch even I am trying to get the location of the touch, and draw an image at the location. Listed below is my code. I am not sure why the image I am trying to place is not drawing at all. I am sure it is not drawing behind the rink image, as i commented this out and the image still doesnt draw when clicked. Here is the touches begin function which should draw the image.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
CGPoint location = [[touches anyObject] locationInView:mainView];
UIImage *image = [UIImage imageNamed:@"small_cone.png"];
[image drawAtPoint:location];
}
Can anyone see why the image will not draw when somewhere is touched? The touchesBegan function start when the screen is touched anywhere, but the picture is not displaying. Thanks for your help, I am newer to objective - c.