Iphone 获取视图的X和Y坐标

Iphone 获取视图的X和Y坐标,iphone,Iphone,我的视图中有一个UITableView。我的UITableView的名称是tblTask。 我正在使用TouchesBegind方法获取视图的x和y坐标。 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:self.view]; NS

我的视图中有一个UITableView。我的UITableView的名称是tblTask。
我正在使用TouchesBegind方法获取视图的x和y坐标。

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView:self.view];

    NSLog(@"point........ %f .. %f",location.x,location.y);



}
但是当我从tbltask开始触摸事件时。即使tbltask是主视图的子视图,它也不会返回location.x和location.y

我还试图禁用表的滚动视图,但什么也没发生。
当我设置这个的时候

tbltask.userInteractionEnabled=NO;

然后它会给出坐标,但即使启用了tbltask交互,我也需要视图坐标。

最简单的方法可能是将
UITableView
子类化,并覆盖
touchesBegined:
touchesMoved:
toucheseEnded:
方法。别忘了调用他们的
[super…]
等价物。ok将尝试。然后让你知道。你能澄清你想要的是什么吗?你的视角的x,y,还是你的触摸的x,y?您的代码将返回触摸的x,y。我的视图的x,y。。但是由于tableview在我的视图前面,我无法获取视图的x,y。可能最简单的方法是将
UITableView
子类化,并覆盖
touchesBegind:
touchesMoved:
toucheseEnded:
方法。别忘了调用他们的
[super…]
等价物。ok将尝试。然后让你知道。你能澄清你想要的是什么吗?你的视角的x,y,还是你的触摸的x,y?您的代码将返回触摸的x,y。我的视图的x,y。。但是因为tableview在我的视图前面,我无法得到我视图的x,y。
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
     UITouch *touch ;
     touch = [[event allTouches] anyObject];
     if ([touch view] == self.view){
         CGPoint location = [touch locationInView:touch.view];
         NSLog(@"point........ %f .. %f",location.x,location.y);
      }
}