gpt4 book ai didi

ios - uitableview 标题 View 问题

转载 作者:可可西里 更新时间:2023-11-01 02:17:22 26 4
gpt4 key购买 nike

我创建了一个 tableview,我有 2 个部分。在第二部分我需要一个标题。所以我像下面那样做了。

  func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 1 {
return 40
}
return 0
}
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 1 {
let header = tableView.dequeueReusableCellWithIdentifier("audiocellheader")! as UITableViewCell

return header
}
else {
return nil
}
}

我在重新加载该部分时遇到问题。标题消失了。如果我执行 tableview.reload 它工作正常。会是什么问题?当我删除单元格中的项目时,我也遇到了问题。图片如下。
enter image description here

header get moves as same as edited row。

最佳答案

我检查了这里的链接 Swipe to delete cell causes tableViewHeader to move with cell得到了答案。

而不是单元格返回 cell.contentview.both 问题已解决

       func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 1 {
let header = tableView.dequeueReusableCellWithIdentifier("audiocellheader")! as UITableViewCell
return header.contentView
}
else {
return nil
}
}

关于ios - uitableview 标题 View 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35935145/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com