현재 iPhone 용 음악 플레이어 응용 프로그램을 작성하려고합니다. 디자인의 일부로 노래 목록의 단일 항목을 스 와이프하여 추가 옵션을 표시 할 수 있습니다 (예 : iOS 7 Mail.app).touchesCancelled가 사용자 지정 UIScrollView를 포함하는 사용자 지정 UITableViewCell을 호출했지만 UITableView didSelectRow가 잘못된 셀에서 실행되었습니다.
커스텀 UITableViewCell의 도움으로 이것을 실현했습니다. 여기에는 사용자 정의 UIScrollView와 두 개의 UIView (실제 내용과 "배경 메뉴")가 포함되어 있습니다. 이는 주로 예상대로 작동합니다.
CellScrollView.m
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
if (![self isDragging]){
[[self superview] touchesBegan:touches withEvent:event];
}
[super touchesBegan: touches withEvent: event];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
if (![self isDragging]){
[[self superview] touchesMoved:touches withEvent:event];
}
[super touchesMoved: touches withEvent: event];
}
-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
if (![self isDragging]){
[[self superview] touchesCancelled:touches withEvent:event];
}
[super touchesCancelled: touches withEvent: event];
}
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event{
if (![self isDragging]){
[[self superview] touchesEnded:touches withEvent:event];
}
[super touchesEnded: touches withEvent: event];
}
을 이제 다음있는 UIScrollView 실제로 노래를 재생하는 옵션을 사용할 수 TableViewCells의 모든 접촉을 취할 듯, 나는 (예를 들어
here 제안으로) 터치 이벤트를 전달 내 문제는 다음과 같습니다. 목록의 셀을 누른 채로 스크롤하면 미디어 플레이어가 예상대로 재생되지 않습니다. 그러나 목록의 다른 항목을 탭하면 내가 밟은 제목은 재생되지 않지만 처음에는 누른 상태에서 스크롤을 시작합니다. 이것은 탭 앤 홀드 (tap-and-hold) 후에 더 이상 탭하여 스크롤을 스크롤하지 않고 멈추지 않는 경우에만 발생합니다 (로그에서 '예기치 않은 터치 단계'가 발생합니다.) 이것이 마침내 탭을 취소 한 것입니다. -보류).
이 동작을 해결할 수있는 방법이 있습니까? (정상적인 UITableViewCell을 사용하면 모든 것이 잘 작동하므로 UIScrollView가 모든 것을 손상시키는 것 같군요)?
자세한 답변을 보내 주셔서 감사합니다. 그 동안 UIPanGestureRecognizer로 전환하여 "손으로"내 견해를 스크롤했습니다. 잠시 동안이 솔루션을 고수 하겠지만, scrollView를 사용하면 다시 볼 수있는 것처럼 보였습니다. 다시 돌아와 다시 시도해 볼 수 있습니다. – dorbeetle