Force uiscrollview to bounce scrolling even with a

2019-06-15 19:06发布

问题:

I have a UIScrollView with varying numbers of items/subviews. When there is more than one item, scrolling bounce works. However, there are times when the scrollview should only have one item, and I would like to provide the feedback to the user that their scrolls are being recognized--thus the bounce effect. However, UIScrollView disables scrolling with just one item.

回答1:

Answer: set alwaysBounceHorizontal or alwaysBounceVertical to true. I answered my own question while writing this up and figured I might as well post it to help others.



回答2:

Additionally, a UIScrollView will not scroll in (width / height) if the contentSize property is not greater than the frame property (in width / height)