简体   繁体   中英

UIView is not scrollable inside scrollview

I have view inside scrollview. Inside UIView there are many objects. I want that view should be scrollable.

这是截图

故事板

Better You can Increase the view controller's Height and add a scroll view with it I hope this video helps.

You need to understand first how UIScrollView works. There should be a warning message that says like this:

ScrollView has ambiguous scrollable content

Your scrollView won't scroll because it means that the subviews of your scrollView does not have enough constraints attached to them and to the scrollView to make the scrollView scroll. Well how does the scrollView scroll? If the content of the scrollView exceeds the frame (either width or height) of the scrollView, then the scrollView will be scrollable.

在scrollview内添加contentview(view)的高度将使scrollview滚动并具有其他必要的约束

I think UIView is not suitable for this kind of situation, because there are many objects aligned vertically, so i prefer to use stack view. Now scroll is working!

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM