我正在從GitHub下載自定義日曆。這是一個自定義視圖,其中添加了UICollectionView以顯示日期單元格。我添加了拖動單元格以獲取多個日期值的功能。對於我添加UILongpressgestureUICollectionView中的長按和平移手勢
我已經試過,
@property (nonatomic, strong) UILongPressGestureRecognizer *dragDateGesture;
self.dragDateGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleDragBeginDate:)];
self.dragDateGesture.delegate = self;
self.dragDateGesture.minimumPressDuration = 0.05;
[self.collectionView addGestureRecognizer:self.dragDateGesture];
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)recognizer
{
return YES;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
return YES;
}
- (void)handleDragBeginDate:(UIPanGestureRecognizer *)recognizer
{
NSLog(@"Gesture recognised");
}
在上面的代碼,我添加了長按姿態,同時設定手勢識別爲是。我不確定是否添加長按手勢將使用UIPanGestureRecognizer getter調用handleDragBeginDate
方法。我是手勢概念的新手。拖拽collectionview時不會調用該方法。
這裏有什麼問題?任何人都可以請指導我呢?
如果我繼續的方式是錯誤的,新的建議將不勝感激。
要在日曆 –