[英]Scroll View and Tableview programmatically alignment
I am implementing a UIScrollView
which holds some user data. 我正在实现一个
UIScrollView
,其中包含一些用户数据。 I am downloading additional data from my server. 我正在从服务器下载其他数据。 Once downloaded the
contentSize
of my UIScrollView
should be the original size + the number of cells times their height. 下载后,我的
UIScrollView
的contentSize
应该是原始大小+单元数乘以它们的高度。
All the UIViews
are aligned and set programmatically. 所有
UIViews
均已通过编程对齐和设置。
The UITableView
is the lowest and is supposed to always stretch to the bottom of the screen. UITableView
是最低的, 应该始终延伸到屏幕底部。
In my viewDidLayoutSubviews I set the following 在我的viewDidLayoutSubviews中 ,设置以下内容
groupsCountLbl.frame = CGRectMake(groupsLbl.frame.maxX + 5,
seperatorLbl.frame.maxY + 15 , 40, 20)
groupsCountLbl.sizeToFit()
table.frame = CGRectMake(0, groupsCountLbl.frame.maxY + 10,
bounds.width, bounds.height - groupsCountLbl.frame.maxY + 10)
scrollView.contentSize = CGSizeMake(bounds.width, bounds.height
+ self.table.frame.height)
scrollView.scrollEnabled = true
Rather than filling the whole view it appears like this: 而不是填充整个视图,它看起来像这样:
Try setting your UIScrollView bounds to superview 尝试将您的UIScrollView范围设置为Superview
NSLayoutConstraint.constraintsWithVisualFormat(
"V:|-[scrollview]-|",
options: [],
metrics: nil,
views: ["scrollview": scrollview])
NSLayoutConstraint.constraintsWithVisualFormat(
"H:|-[scrollview]-|",
options: [],
metrics: nil,
views: ["scrollview": scrollview])
Let me know in the comment if you have some problems 如果您有任何问题,请在评论中让我知道
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.