如何获取不同视图的触摸位置?

Bra*_*ble 0 iphone cocoa-touch touch

触摸可以指定self来获取其自己的坐标系中的触摸位置,但我如何从另一个获取它?说另一个UIview的坐标系?

   - (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];
}
Run Code Online (Sandbox Code Playgroud)

我可以用不同的UIview名称来看待"自我"吗?

drv*_*ijk 5

"此方法返回指定视图的坐标系中UITouch对象的当前位置",所以我会说是,您可以传入另一个视图.确保您可以尝试使用两个视图重叠的示例项目,并对两个视图的两次调用的结果进行NSLog.