iPhone:カスタムUITableViewCellのタップに対応複数の領域を持ちますか?
-
19-09-2019 - |
質問
私は、タップすることができ、複数の領域を持つカスタムのUITableViewCellを作成するように求めてきました。
これらの領域は、ボタンまたは任意のグラフィックスを持っていない - 彼らは目に見えないでしょう。 3つの異なる方法は、ユーザがすなわちタップセルのどの第三に応じて呼び出されます。
|| decrementFooCount || viewFooDetails || incrementFooCount ||
fooNameとfooCount -セルは常に表示する必要があり、それにはいくつかのラベルを持っています
私は、セルの上に、おそらく3隠し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