Reputation: 1395
Touch may specify self to get the touch location in its own coordinate system but how do i get it from another? Say another UIview's coordinate system?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[UIView beginAnimations:@"box" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
UITouch *touch = [touches anyObject];
box.center = [touch locationInView:self];
[UIView commitAnimations];
}
Could I but in the name of a different UIview where 'self' is?
Upvotes: 0
Views: 2259
Reputation: 5554
"This method returns the current location of a UITouch object in the coordinate system of the specified view", so I'd say yes, you can pass in another view. To be sure you could try with a sample project in which you have two views overlap, and NSLog the results of two calls to both views.
Upvotes: 5