繁体   English   中英

ios tableview节标题不粘

[英]ios tableview section header is not sticky

我有一个tableview和tabview(3个不同的选项卡)。我想显示第一个选项卡的4个部分,第二个选项卡的3个部分和。 第三个标签的2部分。 正好第一部分的标题必须位于视图的顶部。因此,我仅在第一部分实现了headerview,但是标题滚动并像表视图单元格一样被隐藏。它没有粘在屏幕顶部,这是什么问题?我必须实现或重写tableview的特定功能吗?

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    if section == 0{
      return UITableView.automaticDimension
    }else {
        return 0 //sadece 1. sectionda tablar header olarak olacak diğerlerinde header olmayacak
    }
}

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
    return CGFloat.leastNormalMagnitude
}

func numberOfSections(in tableView: UITableView) -> Int {
    if dataReady {
        totalSectionCount = getSectionCount()
        return totalSectionCount
    }else {
        return 1 //permanent because of tabview
    }
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
    if !dataReady || ApplicationContext.instance.userAuthenticationStatus.value == .semiSecure{
        return 1//for shimmer cell and semisecure view
    }else {
        return getNumberOfRows(sectionNumber: section)
    }
}

没有任何功能可以限制“ 特定标题”和“ 特定于滚动” 如果您为节定义了标题,则它将向上滚动,并在下一个节标题出现时被隐藏。

在您的情况下,您必须将第一个标题视图/单元格定义为Section Header并在cellForRowAt()方法中管理其他标题。 因为您希望它们向上滚动而不是停留在顶部。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM