2011-04-23 4 views

답변

2

다음과 같은 작업이 있지만 가장 좋은 방법인지는 확실하지 않습니다. 나는 그렇게 생각한다. 모든 thumbViews 이후

은 이하와 같다 kThumbSize 상기 UITouch 인스턴스 (가정 self.multipleTouchEnabled = NO)의 locationInView의 x 좌표 touchesEnded에서 확인 kThumbSize의 폭을 갖는다. 즉, 터치는 thumbView 안에 끝났습니다. 터치가 수직으로 이동하면 thumbViews이 포함 된 tableView이 스크롤되고 터치가 취소되므로 y 좌표를 확인할 필요가 없습니다.

가 (그 인스턴스됩니다 UITableView의 파단) ThumbView : UIView에서 다음을 수행하십시오

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 
    NSLog(@"touchesEnded %@", touches); 
    CGPoint touchPoint = [[touches anyObject] /* only one */ locationInView:self]; 
    if (touchPoint.x >= 0.0f && touchPoint.x <= kThumbSize) { 
     [(ThumbsTableViewCell *)self.superview.superview thumbTouched:self]; 
    } 
} 

전용 레지스터 터치로 하나 thumbView에 한 번을, 당신은 또한 아마의 init 인스턴스 메소드에 self.exclusiveTouch = YES;을 설정하려면 ThumbView.

+1

'if (CGRectContainsPoint (self.bounds, touchPoint)) {...}'이렇게하면 더 멋진 코드를 작성할 수 있습니다. :) – BastiBen

관련 문제