일부 제품을 표시하기 위해 UICollectionView
을 사용하고 있습니다. 사용자 정의 UICollectionViewCell
에는 사용자 정의 UIScrollView
이 있으며 사용자가 빠른 미리보기를 수행 할 수있는 일부 이미지가 있습니다. UICollectionView가 왜 didSelectItemAtIndexPath를 호출하지 않고 스크롤합니까?
UICollectionViewCell
에
UIScrollView
에서 탭 제스처를 전달하려면 :
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if (!self.dragging) {
NSLog(@"Began ==>");
[self.nextResponder touchesBegan:touches withEvent:event];
}
else {
[super touchesBegan:touches withEvent:event];
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
if (!self.dragging) {
NSLog(@"Moved ==>");
[self.nextResponder touchesMoved:touches withEvent:event];
}
else {
[super touchesMoved:touches withEvent:event];
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if (!self.dragging) {
NSLog(@"Ended ==>");
[self.nextResponder touchesEnded:touches withEvent:event];
}
else {
[super touchesEnded:touches withEvent:event];
}
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
if (!self.dragging) {
NSLog(@"Cancelled ==>");
[self.nextResponder touchesCancelled:touches withEvent:event];
}
else {
[super touchesCancelled:touches withEvent:event];
}
}
는 때때로 어떤 경우에는 작동하지 않습니다. 예를 들어 UICollectionView
이 처음로드 될 때 didSelectItemAtIndexPath
메서드를 호출 할 때 호출 할 수 있지만 일부 스크롤 또는 탭 후에 메서드가 더 이상 호출되지 않으면 UICollectionView
을 다시로드하려고해도 여전히 작동하지 않습니다.
UICollectionViewCell
의 터치 방법으로 메시지를 기록하려고 시도하면 & 이벤트가 전달됩니다. 그러나 이 UICollectionView
인 이유는 셀이 제스처를 받으면 호출 되었습니까?
조언을 주시면 감사하겠습니다.
업데이트 : 1. UICollectionViewCell
이 nib 파일에서로드됩니다.
나는'self.superview'를 사용하려고합니다. 그것은 또한 신뢰할 수 없습니다. 실제로 제스처가 셀로 전달됩니다. 그러나 didselect 메서드는 호출되지 않습니다. 아주 이상한. – chancyWu