I tried the following code, but it doesn’t work. How should it be modified?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
location = [touches locationInView:self];
}
In the h files I have defined location like this:
CGPoint location;
The
(NSSet *)toucheswill give you all the current touches on the screen. You will need to go on each touch on this set and get it’s coordinate.These touches are members of UITouch class. Have a look at the UITouch class reference.
for instance you would do:
Cheers!