Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can implement custom paging with this code:</p> <pre><code>- (float) pageWidth { return ((UICollectionViewFlowLayout*)self.collectionView.collectionViewLayout).itemSize.width + ((UICollectionViewFlowLayout*)self.collectionView.collectionViewLayout).minimumInteritemSpacing; } - (void) scrollViewWillBeginDragging:(UIScrollView *)scrollView { CGFloat pageWidth = self.collectionView.frame.size.width + 10 /* Optional Photo app like gap between images. Or use [self pageWidth] in case if you want the next page be also visible */; _currentPage = floor((self.collectionView.contentOffset.x - pageWidth / 2) / pageWidth) + 1; NSLog(@"Dragging - You are now on page %i", _currentPage); } - (void) scrollViewWillEndDragging:(UIScrollView*)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint*)targetContentOffset { CGFloat pageWidth = self.collectionView.frame.size.width + 10; // [self pageWidth] int newPage = _currentPage; if (velocity.x == 0) { // slow dragging not lifting finger newPage = floor((targetContentOffset-&gt;x - pageWidth / 2) / pageWidth) + 1; } else { newPage = velocity.x &gt; 0 ? _currentPage + 1 : _currentPage - 1; if (newPage &lt; 0) newPage = 0; if (newPage &gt; self.collectionView.contentSize.width / pageWidth) newPage = ceil(self.collectionView.contentSize.width / pageWidth) - 1.0; } NSLog(@"Dragging - You will be on %i page (from page %i)", newPage, _currentPage); *targetContentOffset = CGPointMake(newPage * pageWidth, targetContentOffset-&gt;y); } </code></pre> <p>Of course you must set pagingEnabled = NO. _currentPage is a class iVar. Thanks to <a href="http://www.mysamplecode.com/2012/12/ios-scrollview-example-with-paging.html" rel="noreferrer">http://www.mysamplecode.com/2012/12/ios-scrollview-example-with-paging.html</a> for pointing the right way.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload