我制作了一个带有原型单元格的 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 样式设置为简单;我发现了 UITableView Section Header 的 Change Default Scrolling Behavior和https://corecocoa.wordpress.com/2011/09/17/how-to-disable-floating-header-in-uitableview/但我不知道Objective-c(我是 6 个月的快速程序员)。谁能解决我的问题?