19

The bug can be reproduced using the repo here.

I have a strange bug affecting my project in iOS 11 in my UITableView. The TableView in question is grouped, has expandable cells.

Many weird effects happen that are not appearing on my iOS 10 branch:

  1. Titles superposes
  2. weird teleport issues when content size is above the UITableView container size when the collapsing of the cells occur
  3. Weird teleport to top of tableview at the beginning of the scrolling when content size exceeds the container's size
  4. Cell sizing is wrong (quite often)

There is also a ticket that seems related on the Apple Developers forum here.

I tried without any success:

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

I am trying to find the behavior that changed in iOS 11 that could cause this issue.

Any help would be appreciated!

edit: Clipping to bounds helped (but in the end, it hides/clips the problem). I still have a few issues (2, 3 and 4). When I try to unwrap a cell it teleports back to the top instead of going smoothly. When I unwrap a cell and want to scroll to it to it smoothly, it teleports to top then only scrolls to it. (had to add an additional section to show).

Here is a video of the issue (using iPhone 7 Plus, iOS 11, Xcode 9 Golden Master): https://youtu.be/XfxcmmPdeoU

enter image description here

Swift Rabbit
  • 1,370
  • 3
  • 14
  • 29
  • 1
    This question is far too broad for SO. Please focus your question to one single, specific, clear issue. Post relevant code to that one specific issue in your question (not a link to the entire project). Clearly explain the one specific issue. – rmaddy Sep 14 '17 at 16:00
  • I tried it in iOS 11 simulator, and I dont see anything weird except that you would probably want to choose a different approach to collapsing cells, cause now they are not clipped.. – Milan Nosáľ Sep 14 '17 at 16:16
  • @MilanNosáľ Yeah, I forgot to clip to bounds and it helped me fix an issue. Thank you. Do you have the teleport cell issue? You can reproduce by opening the 3 cells, scrolling to bottom, and then closing the last cell. – Swift Rabbit Sep 14 '17 at 16:21
  • nope, does not happen to me.. are you on a device or simulator? which size? i'm going for a run, i'll look into it depper when I come back – Milan Nosáľ Sep 14 '17 at 16:31
  • @MilanNosáľ I am using iOS 8 Plus simulator combined with XCode Golden Master – Swift Rabbit Sep 14 '17 at 16:32
  • @MilanNosáľ So turns out I tried side by side chasing the clip to bounds value, and it did not seem to fix anything :S – Swift Rabbit Sep 14 '17 at 16:37
  • I am seeing similiar things here on my own project. Setting the estimated heights to zero appears to work but then all the auto-layout heights computations are gone ... – vib Oct 02 '17 at 08:07

2 Answers2

24

In iOS 11, all the estimated UITableView properties (estimatedRowHeight, estimatedSectionHeaderHeight, and estimatedSectionFooterHeight) default to UITableViewAutomaticDimension.

I see that for your cells that's fine as you're returning UITableViewAutomaticDimension in heightForRow. For your section headers and footers however you aren't utilizing the auto-sizing. I would try disabling all the auto-sizing behavior in your headers/footers by setting estimatedSectionHeaderHeight, and estimatedSectionFooterHeight to 0.

Source: iOS 11 Floating TableView Header

jvdev7
  • 776
  • 6
  • 6
0

Try this workarround, assuming your IBOutlets and variables are not privates in 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)
    }
}
Patrick Bodet
  • 641
  • 2
  • 8
  • 17