我在xib文件中有以下设置
ScrollView (UIScrollView)
- ContentView (UIView)
- ImageSlider (FSPagerView)
- ClinicName (UILabel)
- ClinicSlogan (UILabel)
- LineSeparatorView (UIView)
- ClinicProfile (UITextView)
- SectionView (Custom UIView)
- Doctors View (UICollectionView) - Horizontal Scrolling
约束按以下方式设置
ScrollView.Top = NavigationView.Bottom
ScrollView.Leading = SafeArea.Leading
SafeArea.Trailing = ScrollView.Trailing
SafeArea.Bottom = ScrollView.Bottom
ContentView.Top = SuperView.Top
ContentView.Leading = SuperView.Leading
SuperView.Trailing = ContentView.Trailing
SuperView.Bottom = ContentView.Bottom
ContentView.Height = SuperView.Height (Priority@250)
ContentView.Width = SuperView.Width
ContentView中的子视图的所有约束都设置为与SuperView(ContentView)相关
viewDidLoad()
我正在更新cliniclampose和ClinicProfile的文本值,并更新height常量。这是可行的,但是当我更新滚动视图的高度时它不起作用,下面是我调用的代码
viewDidLoad()
self.clinicSloganLabelHeightConstraint.constant = estimatedFrameFor(
text: self.clinicSloganLabel.text!,
font: self.clinicSloganLabel.font!,
width: self.clinicSloganLabel.frame.width
).height
self.clinicProfileTextViewHeightConstraint.constant = self.clinicProfileTextView.sizeThatFits(
CGSize(width: self.clinicProfileTextView.frame.width, height: .infinity)
).height
self.scrollView.contentSize.height = 2000
在UIViewController子类中更新滚动视图的高度时,您能帮助我们朝着正确的方向前进吗?
谢谢你