簡體   English   中英

iOS 11 UITableView錯誤

[英]iOS 11 UITableView bug

可以使用此處的repo重現該錯誤。

我的UITableView中有一個影響iOS 11項目的奇怪錯誤。 有問題的TableView被分組,具有可擴展的單元格。

我的iOS 10分支上沒有出現許多奇怪的效果:

  1. 標題重疊
  2. 當單元格折疊發生時,當內容大小高於UITableView容器大小時,會出現奇怪的傳送問題
  3. 當內容大小超過容器大小時,在滾動開始時奇怪的傳送到tableview頂部
  4. 細胞大小是錯誤的(經常)

此處還有Apple開發者論壇上的相關票證。

我試過沒有任何成功

if #available(iOS 11.0, *) {
    tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.never
}

我試圖找到iOS 11中可能導致此問題的更改行為。

任何幫助,將不勝感激!

編輯:剪切到邊界有幫助(但最終,它隱藏/剪輯問題)。 我還有一些問題(2,3和4)。 當我試圖解開一個細胞時,它會傳送回頂部,而不是順利進行。 當我打開一個單元格並想要順利滾動到它時,它會傳送到頂部然后只滾動到它。 (必須添加一個額外的部分來顯示)。

這是一個問題的視頻(使用iPhone 7 Plus,iOS 11,Xcode 9 Golden Master): https//youtu.be/XfxcmmPdeoU

在此輸入圖像描述

在iOS 11中,所有估計的UITableView屬性( estimatedRowHeightestimatedSectionHeaderHeightestimatedSectionFooterHeight )都默認為UITableViewAutomaticDimension

我看到你的細胞很好,因為你在heightForRow返回了UITableViewAutomaticDimension 對於您的部分頁眉和頁腳,但您沒有使用自動調整大小。 我會嘗試通過將estimatedSectionHeaderHeightestimatedSectionFooterHeight設置為0來禁用頁眉/頁腳中的所有自動調整大小行為。

來源: iOS 11浮動TableView標題

試試這個workarround,假設你的IBOutlets和變量不是StandardHeaderView.swift中的私有:

    func toggleSection(section: SectionType) {
    self.sectionsOpened[section] = !self.sectionsOpened[section]!

    let sectionIndex = self.sections.index(of: section)!

    let indexPath = IndexPath(row: 0, section: sectionIndex)

    UIView.animate(withDuration: 0.25) {
        self.tableView.reloadRows(at: [indexPath], with: .automatic)
        if let headerView = self.tableView.headerView(forSection: sectionIndex) as? StandardHeaderView {
            headerView.configWith(title: headerView.headerTitleLabel.text!, isOpen: self.sectionsOpened[section]!, selector: headerView.selector)
        }

        self.tableView.scrollToRow(at: IndexPath(row: 0, section: sectionIndex), at: .top, animated: true)
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM