0

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];
}

我可以以“self”所在的不同 UIview 的名义吗?

4

1 回答 1

5

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

于 2009-07-10T17:47:42.030 回答