Andrew
Andrew

Reputation: 16051

How could I stop UIScrollView from bouncing if there's no scroll distance?

I have a UIScrollView which I want to bounce when it scrolls, but currently it's able to bounce despite the content size being the same as the frame. How can I stop it from bouncing if the content size and frame are the same size? Is there a more elegant way than overriding setContentSize and setFrame with a check for it?

Upvotes: 0

Views: 225

Answers (2)

vaibhav_15
vaibhav_15

Reputation: 351

You can have check that

    if(scrollView.contentSize==frame.size)

    {

       scrollView.bounce = NO;

    }

    else

    {

      scrollView.bounce = YES;

     }

Upvotes: 1

Guy Kogus
Guy Kogus

Reputation: 7351

Use KVO to listen for changes to the content size.

Upvotes: 0

Related Questions