Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 11 UITableView bug

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

like image 900
Swift Rabbit Avatar asked Sep 14 '17 15:09

Swift Rabbit


People also ask

What is UITableView?

UITableView manages the basic appearance of the table, but your app provides the cells ( UITableViewCell objects) that display the actual content. The standard cell configurations display a simple combination of text and images, but you can define custom cells that display any content you want.

Should I use TableView or CollectionView?

Remember, before you make a decision consider if it is just a straight-up list of things with no designs or anything like that, use a TableView. Then if you want more customizability with each cells, like a frame for a portrait, use a CollectionView.

What is IndexPath UITableView?

IndexPath contains information about which row in which section the function is asking about. Base on this numbers you are configuring the cell to display the data for given row.

What class does UITableView inherit from?

The tableview is the instance of the UITableView class, which inherits the UIScrollView class.


1 Answers

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

like image 93
jvdev7 Avatar answered Sep 21 '22 05:09

jvdev7