UIScrollView
의 하위 클래스 인 UICollectionView
에 UILongPressGestureRecognizer
을 추가했습니다. (UIScrollView
은 페이징되어 가로로 3 개가 가로로 쌓여 있습니다. UIViewController
). 내 handleLongPress:
방법에UICcrollView 내의 UICollectionView : 길게 누르기
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
longPress.delegate = self;
longPress.minimumPressDuration = 0.5;
longPress.delaysTouchesBegan = YES;
[self.collectionView addGestureRecognizer:longPress];
과 NSLog
:
내 코드는 UILongPressGestureRecognizer
를 추가합니다. 현재 나는 UICollectionViewCell
을 누르고 있지만 강조 표시되어 있지만 길게 누르면 작동하지 않습니다. 내 UIScrollView
서브 클래스가 길게 누르기를 소비하고 UICollectionView
을지나 가지 않는다고 생각합니다. 손가락을 들어 올리면 didSelectItemAtIndexPath:
메서드가 호출됩니다. 내 UIScrollView
서브 클래스에서
는, 내가 가진 유일한 정의는 다음이 내 UIScrollView
의 페이지 중 하나입니다 내 UITableView
에서 세포 와이프 수 있도록 이루어졌다
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(nonnull UIGestureRecognizer *)otherGestureRecognizer {
// This line enables the swipe to delete in the Messaging VC.
return ([otherGestureRecognizer.view.superview isKindOfClass:[UITableView class]]);
}
. 스 와이프는 아무런 문제가 없으며 여기서는 UICollectionView
및 UICollectionViewCell
에 대한 여러 가지 유사한 검사를 시도했지만 길게 눌러 아직 등록하지 않았습니다. 어떤 충고라도 받아 들였다.
편집 : 다른 UICollectionView
에 길게 누름을 추가했는데 기능적이지만 셀에 강조 표시/선택된 상태가 표시되지 않습니다. 나는 이것이 내가 왜이 긴 언론 제스쳐를 할 수 없는지에 대한 단서라고 생각한다.