簡體   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