2017-09-14 59 views
17

该错误可以使用repo here进行复制。iOS 11 UITableView错误

我的UITableView中有一个奇怪的bug影响我在iOS 11中的项目。 有问题的TableView被分组,有可扩展的单元格。

许多奇怪的效果发生的没有出现在我的iOS 10支:

  1. 标题叠加
  2. 怪异瞬移问题时,内容的大小高于UITableView的容器大小,当细胞的塌陷发生
  3. 当内容大小超过容器尺寸时,在滚动开始时奇怪的传送到tableview顶部
  4. 单元大小设置错误(相当经常)

还有一张票在Apple Developers论坛here上看起来相关。

我想没有任何成功

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

我试图发现,在iOS的11改的行为,可能会导致这个问题。

任何帮助,将不胜感激!

编辑:剪切到界限帮助(但最终,它隐藏/剪辑问题)。我仍然有一些问题(2,3和4)。 当我尝试打开一个单元时,它会传回顶部,而不是顺利进行。 当我打开一个单元格并希望顺利地滚动到它时,它传送到顶部,然后只滚动到它。 (不得不添加一个额外的部分来显示)。

这是问题的一个视频(使用iPhone 7此外,iOS的11时,Xcode 9金主):https://youtu.be/XfxcmmPdeoU

enter image description here

+1

这个问题过于广泛的SO。请将您的问题集中在一个明确的问题上。在相关问题中发布相关代码(不是整个项目的链接)。清楚地解释一个具体问题。 – rmaddy

+0

我在iOS 11模拟器中试过了,我没有看到任何奇怪的东西,除非你可能想要选择不同的方法来折叠单元格,因为现在它们不会被剪切.. –

+0

@MilanNosáľ是的,我忘了夹到边界和它帮助我解决了一个问题。谢谢。你有传送单元的问题吗?您可以通过打开3个单元格,滚动到底部,然后关闭最后一个单元格来重现。 –

回答

22

在iOS系统11,所有评估UITableView属性(estimatedRowHeightestimatedSectionHeaderHeight,和estimatedSectionFooterHeight)默认为UITableViewAutomaticDimension

我看到您的单元格很好,因为您返回UITableViewAutomaticDimensionheightForRow。但是,对于您的部分页眉和页脚,您没有使用自动调整大小。我会尝试通过将estimatedSectionHeaderHeightestimatedSectionFooterHeight设置为0来禁用页眉/页脚中的所有自动调整大小的行为。

来源:iOS 11 Floating TableView Header

+0

如果可以的话,我会抱你,谢谢! –

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