Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在多分区tableview中,tableview分区标头不粘性_Ios_Uitableview_Uitableviewsectionheader - Fatal编程技术网

Ios 在多分区tableview中,tableview分区标头不粘性

Ios 在多分区tableview中,tableview分区标头不粘性,ios,uitableview,uitableviewsectionheader,Ios,Uitableview,Uitableviewsectionheader,我已经在IOS中实现了一个tableview(4)。问题是 我刚刚在第一节中添加了一个节标题。其他节没有标题。第一节没有行(行数为0)。其他节有多行。当我滚动时,第一节的标题不是粘性的。它是滚动的,并且在屏幕外。我的表视图样式是简单的。我如何才能使第一节的标题始终是粘性的。代码如下。不幸的是,表视图太复杂了,我不想使它只有一节,所以我已经实现了多节 func tableView(_ tableView: UITableView, viewForHeaderInSection section: I

我已经在IOS中实现了一个tableview(4)。问题是 我刚刚在第一节中添加了一个节标题。其他节没有标题。第一节没有行(行数为0)。其他节有多行。当我滚动时,第一节的标题不是粘性的。它是滚动的,并且在屏幕外。我的表视图样式是简单的。我如何才能使第一节的标题始终是粘性的。代码如下。不幸的是,表视图太复杂了,我不想使它只有一节,所以我已经实现了多节

func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
    if section == 0 {
        return tabHeaderView.contentView
    }
    else {
        return UIView()
    }
}

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    if section == 0 {
      return UITableView.automaticDimension
    }
    else {
        return 0 //just first section have a header (tabview)
    }
}

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)
    }
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    if ApplicationContext.instance.userAuthenticationStatus.value == .semiSecure {
        semisecureViewCell = EarningsSemisecureViewCell()
        setSemisecureViewTextInfo(cell: semisecureViewCell)
        semisecureViewCell.delegate = self
        semisecureViewCell.layoutIfNeeded()
        return semisecureViewCell
    }
    else if !dataReady {
        return getShimmerCell()
    }
    else {
        if indexPath.row == 0 && !(selectedTabIndex == .BRANDPOINT && indexPath.section == 1){//marka puan listesinde header cell olmayacak
            return getSectionHeaderViewCell(tableView: tableView,sectionNumber: indexPath.section)
        }
        else {
            let cell = getTableViewCell(tableView: tableView, indexPath: indexPath)
            cell.layoutIfNeeded()
            return cell
        }
    }
}

如果在任何部分显示时,第一部分必须始终是粘性的,我会考虑在TabView的顶部放置自定义视图。使用AutoLayOutlook或UISTACKView让它作为表标题视图工作。

< P>如果在任何部分显示时第一节必须始终是粘性的,我将考虑在TabView的顶部放置自定义视图。使用autoLayout或UIStackView将其用作表格标题视图。

从您描述设置的方式来看,我倾向于认为您要查找的是
表格视图的
表格标题视图,而不是节标题

有关更多信息,请参见或


如果不符合您的要求,您可能想在代码> > TabelView < /C>中考虑自定义视图。

< P>从您如何描述您的安装程序,我倾向于相信您正在寻找的是 Table HealthView <代码> > >,而不是区段头。

有关更多信息,请参见或


如果不符合您的要求,您可能需要考虑在 TabelView < /C>中的自定义视图,如所描述的。

< P>每个区段头将坚持到顶部,直到该段有一些行才能显示。一旦您向上滚动该部分的所有行。节标题将替换为下一节标题

在这里,您可以使用两种解决方案之一

  • 而不是表视图节标题。将您的视图置于UITableView之上
  • 您只能使用一个部分并合并其中的所有行

  • 每个节标题都将粘贴到顶部,直到该节有一些行要显示。一旦您向上滚动该部分的所有行。节标题将替换为下一节标题

    在这里,您可以使用两种解决方案之一

  • 而不是表视图节标题。将您的视图置于UITableView之上
  • 您只能使用一个部分并合并其中的所有行

  • 我编辑它。First section eHeader必须是粘性的。getSectionCount()方法的代码在哪里?抱歉,我忘记了。section count没有问题,但我已将代码更改为仅一个section,并且我管理了一个section中的所有单元格。完成了。谢谢您的回答。我编辑它。First section eHeader必须是粘性的。getSectionCount的代码在哪里()方法?对不起,我忘了。分区计数没有问题,但我已将代码更改为只有一个分区,并且我管理了分区中的所有单元格。完成了。谢谢您的回答。我还有一个tableheaderview。我想我必须将所有分区合并在一个分区中。我还有一个tableheaderview。我想我必须将所有分区合并在一个分区中。我还有一个tableheaderview。我认为你是对的。我必须将所有内容合并到一个部分。非常感谢:)解决方案1很好将视图放在tableView的顶部,或将视图添加到tableView的同一父视图中。我还有一个tableheaderview。我认为你是对的。我必须将所有内容合并到一个部分中。非常感谢:)解决方案1很好。:)将视图放在tableView的顶部,或将视图添加到tableView的同一父视图中。