18

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.

Bushra Shahid
  • 3,579
  • 1
  • 27
  • 37
perr200
  • 181
  • 1
  • 1
  • 4
  • What do you mean by "bouncing between pages"? The whole point of bouncing is to "bounce" when user reaches any edge of the scrollview, there is no bouncing between pages in pagingEnabled scroll view. – Filip Radelic Aug 09 '11 at 22:14
  • If i have 10 "pages" in the scrollview.. When I swipe from page 2 to page 3( for example) I get randomly this results : -page 3 reach is border with little "bounce" (going back and forth) -page 3 reach is border, and i can see little of page 4 before bounce back -page 3 reach is border and stop(and that's what i want) again, the animation of swiping is not constant, and it's not UI Friendly. Hope I'm clear here. – perr200 Aug 09 '11 at 22:33
  • the behavior depends on how much you drag before releasing, check the scroll delegate methods to see if you can control it with more detail – bshirley Aug 09 '11 at 23:31
  • hi perr200. i have exactly the same problem,did you find any solution to this please let me know. – Hariprasad May 03 '12 at 09:47
  • Hey there, do u use `XLPagerTabStrip` framework? I had this prob but available to solve simply. – S At Oct 15 '17 at 13:09

4 Answers4

18

just do this:

_scrollView = [[UIScrollView alloc]init];
_scrollView.pagingEnabled = YES;
_scrollView.bounces = NO; //Here

then, no bounce any more!

Bruce Lee
  • 4,177
  • 3
  • 28
  • 26
1

If you set a delegate for your UIScrollView, the delegate will receive scrollViewWillBeginDecelerating: when the user lifts their finger off the screen. You may then be able to take control using the UIScrollView's setContentOffset:animated: method to scroll the nearest page into view, or set up your own animation using the animateWithDuration:animations: method – I'm not sure whether your own animation will take precedence over the already-in-progress deceleration, though.

You can also set the UIScrollView's decelerationRate to UIScrollViewDecelerationRateFast, which may make the scrolling more consistent in this situation.

Scott Forbes
  • 7,397
  • 1
  • 26
  • 39
1

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
}
0

set scrollbar's bounce property false/no....it will not bounce after that... try it hope yu will get your solution....

viral shah
  • 93
  • 1
  • 5