UIScrollView and its subclasses won't bounce if nested in custom UIView
Originator: | nskboy | ||
Number: | rdar://8045239 | Date Originated: | 31-May-2010 05:48 PM |
Status: | Open | Resolved: | |
Product: | iPhone SDK | Product Version: | 3.1.3/10M2148 |
Classification: | Other bug | Reproducible: | Always |
31-May-2010 05:48 PM Roman Busyghin: Summary: UIScrollView and its subclasses won't bounce if they are nested into custom UIView. Scroll view starts bouncing when it is nested into plain UIView. Steps to Reproduce: 1. Run the attached sample code and try to make scroll view bouncing by dragging it to the one of its edges Expected Results: UIScrollView should bounce normally Actual Results: It won't bounce Regression: Problem exists in both 3.1.3 and 4.0. To workaround this problem you should put additional UIView between custom UIView and your UIScrollView. Notes:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Also saved me lots of time!
Better solution
The underlying problem here is if you set the scrollview's frame/bounds in -layoutSubviews, it doesn't check if you're setting it to the frame/bounds that it already has, and this cancels the bounce. The solution is to do something like
CGFrame scrollFrame = [self calculateFrameForScrollView]; if (!CGRectEqualToRect(scrollFrame, self.myScrollView.frame)) { self.myScrollView.frame = scrollFrame; }
I wish I found this earlier
Many thanks!
I tried to solve my problems with scroll view for about 12 hours before found this. Worked like a charm.
Thanks again!
Just wanted to also say thanks - this tip saved me an otherwise inevitable headache and long frustrating debugging process.
Thank you kballard!
It works perfectly for me.