Reputation: 181
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.
Upvotes: 18
Views: 18662
Reputation: 59
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
}
Upvotes: 2
Reputation: 4431
just do this:
_scrollView = [[UIScrollView alloc]init];
_scrollView.pagingEnabled = YES;
_scrollView.bounces = NO; //Here
then, no bounce any more!
Upvotes: 19
Reputation: 93
set scrollbar's bounce property false/no....it will not bounce after that... try it hope yu will get your solution....
Upvotes: 0
Reputation: 7417
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.
Upvotes: 1