Hi I want to make it so that if you touch an image that I put on the view the -(void)checkcollision happens. The -(void)checkcollision happens, but when I touch anything. How can I say it only works if i touch a specified image. e.g. a pimple:
IBOutlet UIImageView *pimple;
@property (nonatomic, retain) UIImageView *pimple;
here is the touchesBegan code
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [[event allTouches] anyObject];
[self checkcollision];
}
-(void)checkcollision {
if (label.text = @"0") {
label.text = @"1";
}
pimple.hidden = YES;
}
There are two options:
UIImageView
and define your own handler- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
and compare it to yourUIImageView
instance.Alternatively you can consider
gesture recognizers
. You can use a tap recognizer for this case.