[英]Swift - contents within scrollview get chop off
Facing an issue when scrolling, a part of content didn't displayed.滚动时遇到问题,部分内容没有显示。
https://i.stack.imgur.com/70FIC.png https://i.stack.imgur.com/70FIC.png
Here it is what is supposed to be displayed这是应该显示的内容
https://i.stack.imgur.com/ViPjF.png https://i.stack.imgur.com/ViPjF.png
My UI is designed in storyboard, the structure for the scrollable component is as below:我的UI设计在storyboard,滚动组件的结构如下:
UIView -> UIScrollView -> UIStackView -> Multiple UIViews UIView -> UIScrollView -> UIStackView -> 多个 UIViews
If wondering how I take the screenshot of the one that's supposed to be displayed, the price is a drawer component, somehow after I tapped the drawer component, the content will be displayed, but after I scroll to top, same issue will happen to the content, which they get chop off.如果想知道我应该如何截取应该显示的屏幕截图,价格是一个抽屉组件,不知何故我点击抽屉组件后,内容会显示,但当我滚动到顶部后,同样的问题会发生在内容,他们被砍掉了。
https://i.stack.imgur.com/OKSEY.png https://i.stack.imgur.com/OKSEY.png
Updates:更新:
Trying to put background colour on views to see which view is blocking the scrollview.尝试将背景颜色放在视图上以查看哪个视图阻塞了滚动视图。
https://i.stack.imgur.com/vZBY7.png https://i.stack.imgur.com/vZBY7.png
Found that the scrollview (Booking DetailsSV) blocked by its superview (Booking Details View) in the hierarchy.发现scrollview(Booking DetailsSV)在hierarchy中被它的superview(Booking Details View)挡住了。 Here is the screenshot taken in the test phone.
这是在测试手机中截取的屏幕截图。
https://i.stack.imgur.com/Wm7xa.png https://i.stack.imgur.com/Wm7xa.png
Is it suppose to happen like this?它应该像这样发生吗?
Your scrollview doesn't seem to have correct contentSize.您的滚动视图似乎没有正确的 contentSize。 You need to set content size of your scrollView like following:
您需要像下面这样设置 scrollView 的内容大小:
let sizeOfContent = 500
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, sizeOfContent);
You can do this in viewDidLoad.您可以在 viewDidLoad 中执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.