UIVIew inside UIScrollView bounces back

血红的双手。 提交于 2019-12-10 18:26:14

问题


MY app is for iPad using Storyboards with two scenes. On one scene, I have a UIScrollView that contains a UIVIew. It scrolls, but bounces back immediately, rendering itself useless. The size of the UIScrollView is 768x590; the size of the UIView is 768x1590; ContentSize of the UIScrollView is 768x590. This is an image of the UIScrollView settings:

(I have looked at SO and Google for the past 6 hours, tried a lot of stuff, but nothing works. I have also done a CMD + Option + K (Clean) several times, and that didn't help either.

Why does it not scroll properly?


回答1:


Found what works for me!

When you embed a view into a UIScrollView in InterfaceBuilder, then there's a constraint automatically set. If your view is "longer" than the screen in portrait, it wont scroll at all.

But if you rotate the screen, you'll notice the ability to scroll a little.

To get UIScrollView going in AutoLayout look into your constraints.

Find "Vertical Space - Scroll View - View" and set it from "constant" to "auto" - fixed everything for me.

Thanks for your help... I appreciate it.




回答2:


Your scrollView height is less than the uiview which is the subview in your case of scrollview and for scrolling it fully you will have to set your scrollview contentSize height more than the height of the view you are scrolling in it,please give a check on this point.



来源:https://stackoverflow.com/questions/13317829/uiview-inside-uiscrollview-bounces-back

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!