다음은 스크롤 뷰의 하위 클래스에 작성해야하는 코드의 전체 코드입니다.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if (self.dragging) {
[super touchesBegan:touches withEvent:event];
} else {
[self.superview touchesBegan:touches withEvent:event];
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
if (self.dragging) {
[super touchesMoved:touches withEvent:event];
} else {
if ([self.delegate isKindOfClass:[UITableViewCell class]]) {
[(UITableViewCell *)self.delegate touchesCancelled:touches withEvent:event];
}
[self.superview touchesMoved:touches withEvent:event];
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
if (self.dragging) {
[super touchesEnded:touches withEvent:event];
} else {
[self.superview touchesEnded:touches withEvent:event];
}
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
if (self.dragging) {
[super touchesCancelled:touches withEvent:event];
} else {
[self.superview touchesMoved:touches withEvent:event];
}
}
touchesMoved
에는 내가 만났던 버그를 기반으로하는 몇 가지 추가 코드가 있습니다. 시작하려면 self.delegate
이 UITableViewCell
이 아닌 경우 속성을 셀로 바꾸십시오.
셀은 바람직하지 않은 결과를 방지하기 위해 이동 중에 취소 터치 이벤트를 검색해야합니다. 다음과 같이 쉽게 재현 할 수 있습니다.
- 강조 셀 셀이 강조되는 동안
- , 다른 셀을 선택 테이블 뷰
- 를 끌어 지금은 (스크롤 뷰를 가정 스크롤 뷰를 선택하지 않을 경우 전체 세포 이상) 이전에 강조 표시된 셀은
didSelectCell
상태를 검색합니다.
또 다른 요지는 순서 문제입니다! self.delegate
이 self.superview
전에 호출되지 않으면 강조 표시된 상태가 발생하지 않습니다.
앱이 텍스트를 스크롤하려는 경우 또는 테이블을 스크롤하려는 경우 어떻게 알 수 있습니까? 스크롤 뷰가 셀 뷰의 일부만 차지한다고하더라도 사용자가 인터페이스에 혼란을 느끼고 작동하지 않는다고 생각합니다. – ader
응용 프로그램은 다음과 같이 알 수 있습니다. 미니 스크롤보기 프레임 내에서 탭하면 각 셀 (물론 큰 텍스트가있는 경우) 내에서 스크롤해야하며 모든 셀 프레임의 테두리 바깥을 탭하면 기본 스크롤 테이블 뷰의 유효성을 확인하고 원하는 스크롤을 제공해야합니다. – JAHelia
세포가 얼마나 높다고 생각하십니까? 귀하의 사용자가 인터페이스에 혼동을 느끼고 작동하지 않는다고 생각합니다. UI 디자인을 다시 고려해 보는 것이 좋습니다. 어쩌면 수직 페이징이있는 스크롤 뷰가 더 잘 작동 할 것입니다. – ader