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

Iphone 触摸(手势)在屏幕上有桌子的部分无法识别,iphone,objective-c,ios,xcode,Iphone,Objective C,Ios,Xcode,我希望能够处理发生在屏幕所有部分的手势,而不仅仅是UITableView未涵盖的部分 这可能吗?如果是这样,我怎样才能让它工作 这是我用来收集触摸数据的代码。我想我有这句台词 UITouch *t = [touches anyObject]; 允许我收集所有的触摸 -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *t = [touches anyObject]; CGPoint curren

我希望能够处理发生在屏幕所有部分的手势,而不仅仅是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");
}
-(无效)触摸移动:(NSSet*)触摸事件:(UIEvent*)事件
{
UITouch*t=[触摸任何对象];
CGPoint currentPosition=[t locationInView:self.view];
CGFloat positionDelta=当前位置.x-_原始触摸位置.x;
如果(位置增量>50.0)
{
NSLog(@“X”);
}
否则如果(位置增量<-50.0)
{
NSLog(@“Y”);
}
否则如果(位置增量>1)
{
NSLog(@“Z”);
}
其他的
{
回来
}
}
-(无效)触摸开始:(NSSet*)触摸事件:(UIEvent*)事件
{
UITouch*t=[触摸任何对象];
_originalTouchPosition=[t locationInView:self.view];
NSLog(@“触摸开始”);
}
-(void)touchesend:(NSSet*)toucheevent:(UIEvent*)event
{
NSLog(@“tocuhes ended”);
}
非常感谢,,
-Code

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

您可以使用uitappesturerecognizer并将其添加到视图中,这样不可编辑的组件(与UITextField和其他组件不同)将接收所有事件(甚至是UITableView)但糟糕的是,它会锁定这些组件的本机事件。因此,请尝试将tap事件传递给正确的UI元素。我知道这不是一个完整的解决方案,但也许你可以看看这是否适合你。