[英]How to show tableView to top when scrolled
In my project, In the view 'Top' side is for one UIView and below it a tableView. 在我的项目中,在视图中“顶部”侧是一个UIView,下面是一个tableView。 I want to show tableView to top when scrolled and hide the tableView.
我想在滚动时将tableView显示到顶部并隐藏tableView。
func scrollViewDidScroll(_ scrollView: UIScrollView) {
self.topView.isHidden = true }
Please give me solution for how to show tableView to top when tableView scrolled. 请给我解决方案,以便在tableView滚动时如何将tableView显示到顶部。 Below is the screenshot [![enter image description here][1]][1]
下面是截图[![在此处输入图像描述] [1]] [1]
in this view bottom is tableView and top is UIView. 在这个视图中底部是tableView,顶部是UIView。 Below is the storyboard screenshot.
以下是故事板截图。
The simplest solution is to set that topView
as tableHeaderView
. 最简单的办法是设置
topView
作为tableHeaderView
。
self.tableView.tableHeaderView = topView
Now when you scroll the tableView
topView
will goes up with it. 现在,当您滚动
tableView
topView
将会启动它。 Also no need to implement scrollViewDidScroll
now. 现在也不需要实现
scrollViewDidScroll
。
Select your tableview
in your Controller
of Storyboard
在
Controller
of Storyboard
选择您的tableview
TableView
TableView
Attributes Inspector
on the right panel of Utilities Attributes Inspector
Style
to Grouped
Style
设置为Grouped
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.