Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable gesture swipe for UICollectionView

Currently, I'm making paging UICollectionView. I want to disable gesture swipe effect from UICollectionView as I'm going to add UIPagerControl to animate the paging UICollectionView. I don't want user uses their finger to move to next screen instead of using custom UIPageControl.

like image 722
AndroidBeginner Avatar asked Mar 17 '23 22:03

AndroidBeginner


1 Answers

A UICollection inherits from UIScrollView and the user's scrolling can be disable this way:

myCollectionView.scrollEnabled = NO;

Here is the documentation explanation (UIScrollView class reference):

When scrolling is disabled, the scroll view does not accept touch events; it forwards them up the responder chain.

When using your UIPageControl, you can programmatically set the position in your UICollectionView using the UIScrollView method:

- (void)setContentOffset:(CGPoint)contentOffset
                animated:(BOOL)animated
like image 193
paillou Avatar answered Apr 01 '23 05:04

paillou