Scrolling UITableView / UICollectionView looks too much after Xcode 9.0 and iOS 11

I have four pages in an application for iPhone. All 4 pages are a subclass of UIViewController. On two pages, a UITableView displays a list of items. On two pages, a UICollectionView displays data. All data is retrieved from the web service using AFNetworking. It is very good without any problems. I show custom cells from the storyboard for tableView and collectionView with all the necessary and recommended methods.

It used to show smooth scrolling in the simulator and devices before I upgraded my Xcode 8.3 to Xcode 9.0 and iOS 11. I tried using this solutions as well as other possible solutions from SO, but it does not solve my problem. The most confusing part is that I did not change one line of code for the tableView or collectionView, and it began to show a mutable effect.

It seems like he is waiting for something every second and even scrolls with a noticeable pause - although I do not have complex logic when displaying data. I just show the data as it happens in a web service response. I also have a branch that used to show smooth scrolling with Xcode 8.3, but when I run the same code with Xcode 9.0, it shows mutable scrolling.

I am using macOS 10.12.6, Xcode 9, Swift 4 and simulators with iOS 11 and iOS 10.3.

+5
source share
2 answers

We have found a workaround for this problem! If you just implement

-[UITableView tableView:estimatedHeightForRowAtIndexPath:] 

and return

 -[UITableView tableView:heightForRowAtIndexPath:] 

everything will work.

Update: It turns out that the core of the problem is that when assigning a new UITableView with Xcode 8, the default value for UITableView.estimatedRowHeight is 0, whereas if you do the same with Xcode 9, the default value is -1 or UITableViewAutomaticDimension . Returning to 0 resolves the issue.

+2
source

Set isPrefetchingEnabled of your collection view to false, OR (which solves the problem better), use the prefetch methods in UICollectionViewDataSourcePrefetching / UITableViewDataSourcePrefetching to get a smoother and more efficient scroll. Do any web upload where the data is ready to create a cell.

+1
source

Source: https://habr.com/ru/post/1272989/


All Articles