简体   繁体   中英

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

Here it is what is supposed to be displayed

https://i.stack.imgur.com/ViPjF.png

My UI is designed in storyboard, the structure for the scrollable component is as below:

UIView -> UIScrollView -> UIStackView -> Multiple 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

Updates:

Trying to put background colour on views to see which view is blocking the scrollview.

https://i.stack.imgur.com/vZBY7.png

Found that the scrollview (Booking DetailsSV) blocked by its superview (Booking Details View) in the hierarchy. Here is the screenshot taken in the test phone.

https://i.stack.imgur.com/Wm7xa.png

Is it suppose to happen like this?

Your scrollview doesn't seem to have correct contentSize. You need to set content size of your scrollView like following:

let sizeOfContent = 500

scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, sizeOfContent);

You can do this in viewDidLoad.

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