Can't disable bounce with UIScrollView and pagingEnabled=YES

Viewed 16735

I have UIViewController that hold UIScrollView inside it.

The m_scrollView is with pagingEnabled=YES;

On each "page" I have UIViewController that display article.

To prevent bouncing when the user swipe from page to page i used :

m_scrollView.bounces=NO;

and even

m_scrollView.alwaysBounceHorizonal=NO;

I notice the change was only to the last page that is not bounce. But when swiping the other pages, they bounce.

EDIT: the optimal solution was make the first and last page bounce ( so the user will get repsond there is no more pages\paging) and the other pages without bouncing

the annoying with the bounce when swiping pages is the bounce effect is not equal and same. somtimes it bounce more, and somtimes less.

I tought is somthing to do with the loading data in the pages, but I dont think it's the case, cause it happens also when all pages are loaded and no async operation of loading are happening in the background. Any ideas ?

EDIT 2 : I guess the bounce property is about the edge of the UIScrollView, But when moving from page to page there is also bouncing. Sometimes I can see a little of next-next page. For example : swiping from page 2 to page 3 , and in the animation of swiping I can see for 0.1 second page 4.

Also, the animation of swiping is not constant. and it feel that each swipe acts little diffrent. Thanks in advance.

4 Answers

Bouncing refers only to the edges of the content. Not the the small movement when swiping from page to page.

This movement is caused by the paging effect.

It also happens when setting the scrollView.isPagingEnable to true when the page is already on the page.

To prevent this movement, I had to set the paging to false before calling:

collectionView.isPagingEnabled = false

collectionView.setContentOffset(requiredOffset, animated: true)

and set the paging back to true in:

func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
    collectionView.isPagingEnabled = true
}
Related