[英]iOS 11 UITableView bug
可以使用此處的repo重現該錯誤。
我的UITableView中有一個影響iOS 11項目的奇怪錯誤。 有問題的TableView被分組,具有可擴展的單元格。
我的iOS 10分支上沒有出現許多奇怪的效果:
此處還有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
屬性( estimatedRowHeight
, estimatedSectionHeaderHeight
和estimatedSectionFooterHeight
)都默認為UITableViewAutomaticDimension
。
我看到你的細胞很好,因為你在heightForRow
返回了UITableViewAutomaticDimension
。 對於您的部分頁眉和頁腳,但您沒有使用自動調整大小。 我會嘗試通過將estimatedSectionHeaderHeight
和estimatedSectionFooterHeight
設置為0
來禁用頁眉/頁腳中的所有自動調整大小行為。
試試這個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.