我被要求创建一个自定义 UITableViewCell ,其中包含多个可以点击的区域。
这些区域没有按钮或任何图形——它们是不可见的。将调用 3 种不同的方法,具体取决于用户点击的单元格的哪三分之一,即
|| 递减FooCount || viewFoo详情 || 增量FooCount ||
单元格上有一些需要始终可见的标签——fooName 和 fooCount。
我在想单元格上可能有三个隐藏的 UIButtons?
我还需要保持滑动以删除默认行为。
我被要求创建一个自定义 UITableViewCell ,其中包含多个可以点击的区域。
这些区域没有按钮或任何图形——它们是不可见的。将调用 3 种不同的方法,具体取决于用户点击的单元格的哪三分之一,即
|| 递减FooCount || viewFoo详情 || 增量FooCount ||
单元格上有一些需要始终可见的标签——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];
}
}
安德鲁