Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop a UIScrollView from scrolling when it reaches the bottom

I have the following code in place to grab the event when a UIScrollView reaches then end of its content view:

- (void) scrollViewDidEndDecelerating:(UIScrollView *) scrollView
{
    float currentEndPoint = scrollView.contentOffset.y + scrollView.frame.size.height;

    // CGPoint bottomOffset = CGPointMake(0, scrollView.contentSize.height - scrollView.bounds.size.height);
    // [scrollView setContentOffset:bottomOffset animated:NO];

    if (currentEndPoint >= scrollView.contentSize.height)
    {
        // We are at the bottom

I notice that when I scroll to the bottom it hits it and bounces back up.

If I add this:

CGPoint bottomOffset = CGPointMake(0, scrollView.contentSize.height - scrollView.bounds.size.height);
[scrollView setContentOffset:bottomOffset animated:NO];

then the scroll goes back to the bottom.

Is there any way for it to stay at the bottom without the "bounce back up" as in once it hits the bottom, stop it from moving.

Thanks.

like image 697
cdub Avatar asked Dec 05 '25 04:12

cdub


1 Answers

You should uncheck the bounce property of scrollview. Check the screenshot!

enter image description here

like image 163
Ritu Avatar answered Dec 07 '25 18:12

Ritu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!