iPhone:自定义UITableViewCell有多个响应水龙头的区域?

N. *_*ham 3 iphone touch uitableview

我被要求创建一个自定义的UITableViewCell,其中包含多个可以点击的区域.

这些区域没有按钮或任何图形 - 它们将是隐形的.将根据用户点击的第三个单元格调用3种不同的方法

|| decrementFooCount || viewFooDetails || incrementFooCount ||

单元格上有一些标签,需要始终可见--fooName和fooCount.

我想在细胞上可能有三个隐藏的UIButton?

我还需要保持滑动以删除默认行为.

And*_*rew 5

您可以继承您的UITableViewCell并覆盖该touchesBegan:withEvent:方法.然后,您可以获得触摸所在位置的CGPoint.

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

   if (CGRectContainsPoint(myTestRect, location)) {
       // Touched inside myTestRect, do whatever...
   } else {
      // Let the default implementation take over.
      [super touchesBegan:touches withEvent:event];
   }
}
Run Code Online (Sandbox Code Playgroud)

安德鲁