views:

211

answers:

3

I have a UIScrollView contained within a custom UIView with a content size larger than the ScrollView's frame.

I am able to drag scroll as I expect, but the thing doesn't give me the rubber banding effect that you get with the UITableView or UIWebView. It just stops when you get to one of the extremes.

I have set bounce = YES, is there something else I'm supposed to do?

I read the docs, and they say I have to implement the delegate. I did that.

They also say I should change the zoom levels, but I don't want the user to actually be able to zoom so I haven't set these.

A: 

That is interesting... Is there a lot going on while the user scrolls the scroll view? Maybe that could cause the problem. The iPhone can multitask, but not too much. Can I see your entire code having to do with the scroll view?

Flafla2
Nothing interesting going on at all! There's just a scroll view with a large UIView added as a subview whose frame is the same size as the scroll view's content size. The subview has a bunch of custom UIViews as children.
Frank Krueger
A: 

It turns out that keeping the UIScrollView within my custom UIView was causing the trouble.

Once I switched my custom UIView to instead inherit from UIScrollView, then the bouncing started working.

Frank Krueger
Here's what was happening: http://openradar.appspot.com/8045239
leolobato
A: 

For anyone that finds this thread later, if you are subclassing UIView and re-setting the UIScrollView's frame on every layoutSubviews, that is the problem - it cancels the bounce:

http://openradar.appspot.com/8045239

You should do something similar to this:

- (void)layoutSubviews;
{
    [super layoutSubviews];

    CGRect frame = [self calculateScrollViewFrame];
    if (!CGRectEqualToRect(frame, self.scrollView.frame)) 
        self.scrollView.frame = frame;
}
leolobato