我被要求创建一个自定义的UITableViewCell有可以挖掘多个区域。

这些地区不会有按钮或任何图形 - 他们将是无形的。 3种不同的方法将根据用户敲击即小区的其中第三被调用。

|| decrementFooCount || viewFooDetails || incrementFooCount ||

在细胞有需要在任何时候都可见它的几个标签 - 在fooName和fooCount

我想也许三个隐藏UIButtons在细胞?

我还需要维护的滑动删除默认的行为。

有帮助吗?

解决方案

您可以继承你的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];
   }
}

安德鲁

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top