触摸(手势)在有桌子的部分屏幕上无法识别

时间:2011-09-13 17:13:47

标签: iphone objective-c ios xcode

我希望能够处理屏幕各部分发生的手势,而不仅仅是UITableView未覆盖的部分。

这可能吗?如果是这样,我怎么能让它运作?

这是我用来收集触摸数据的代码。我虽然有这条线

UITouch *t = [touches anyObject];

允许我收集所有接触。

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{

UITouch *t = [touches anyObject];

CGPoint currentPosition = [t locationInView:self.view];

CGFloat positionDelta = currentPosition.x-_originalTouchPosition.x;

if (positionDelta > 50.0)
{
    NSLog(@"X");
}
else if (positionDelta < -50.0)
{
    NSLog(@"Y");
}
else if (positionDelta > 1)
{
    NSLog(@"Z");
}
else 
{
    return;
}
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{

UITouch *t = [touches anyObject];
_originalTouchPosition = [t locationInView:self.view];
NSLog(@"touches began");
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"tocuhes ended");
}

非常感谢, -code

1 个答案:

答案 0 :(得分:0)

对UITableViewCell进行子类化并在该子类中应用-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event方法,然后您就可以检测到UITableView上的触摸,并且您可以使用UITableView的正常功能。