2010-03-10 5 views
3

나는 탭 할 수있는 여러 영역으로 사용자 정의 UITableViewCell을 생성하라는 요청을 받았습니다.iPhone : 탭에 응답하는 여러 영역이있는 사용자 정의 UITableViewCell?

이 영역에는 버튼이나 그래픽이 없으므로 보이지 않습니다. 사용자가 누르는 셀의 1/3에 따라 3 가지 메소드가 호출됩니다. 즉

|| 감소 FooCount || viewFooDetails || incrementFooCount ||

셀에는 fooName과 fooCount가 항상 표시되어야하는 몇 개의 레이블이 있습니다.

셀 위에 숨겨진 UIButton이 3 개 있다고 생각합니까?

또한 기본 동작을 삭제하려면 스 와이프를 유지해야합니다.

답변

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

앤드류

+0

이 좋아 보인다. 감사! –

관련 문제