3

タップできる複数の領域を持つカスタムUITableViewCellを作成するように依頼されました。

これらの領域にはボタンやグラフィックはありません-それらは非表示になります。ユーザーがセルの3分の1をタップするかどうかに応じて、3つの異なるメソッドが呼び出されます。

|| decrementFooCount || viewFooDetails || 増分FooCount||

セルには、常に表示する必要のあるいくつかのラベル(fooNameとfooCount)があります。

私はおそらくセルの上に3つの隠されたUIButtonを考えていますか?

また、デフォルトの動作を削除するには、スワイプを維持する必要があります。

4

1 に答える 1

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];
   }
}

アンドリュー

于 2010-03-10T07:21:24.243 に答える