iPhone:自定义的UITableViewCell与应对水龙头多个区域?
-
19-09-2019 - |
题
我被要求创建一个自定义的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];
}
}
安德鲁
不隶属于 StackOverflow