【发布时间】:2026-02-23 07:00:02
【问题描述】:
我制作了一个带有原型单元格的 TableView;在 tableView 的第一个位置我做了这个
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 0
{
let view : UIView = UIView(frame: CGRectMake(0, 0, 400, 140))
view.backgroundColor = UIColor.redColor()
view.addSubview(populateView())
//populateView() is a method by which I programmatically made all object in the view (label, images, textView)
return view
}
else
{
return nil
}
}
override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
{
if section == 0
{
return 140
} else
{
return 0
}
}
现在我想让 TableHeaderView 不随 tableView 滚动;我将 tableView 样式设置为简单;我找到了这个Change Default Scrolling Behavior of UITableView Section Header 和这个https://corecocoa.wordpress.com/2011/09/17/how-to-disable-floating-header-in-uitableview/,但我不知道Objective-c(我是6 个月以来的快速程序员)。谁能解决我的问题?
【问题讨论】:
标签: swift uitableview cells tableheader