UITableView/UICollectionView scrolling looks choppy after Xcode 9.0 and iOS 11
Asked Answered
S

2

6

I have four pages in the iPhone app. All 4 pages are subclass of UIViewController. Two pages have UITableView to show list of items. Two pages have UICollectionView to show data. All data fetched from web-service with help of AFNetworking. It comes very well without any issues. I show custom cells from storyboard for tableView and collectionView with all required and recommended methods.

It used to show smooth scrolling in simulator and devices before I updated my Xcode 8.3 to Xcode 9.0 and iOS 11. I tried with solutions from this and also other possible solutions from SO but does not solve my problem. Most confusing part is that I did not change single line of code for tableView or collectionView and it started showing choppy effect.

It looks like it waits for something every second and scrolling with noticeable pause even-though I do not have any complex logic while showing data. I just show data as it comes in web-service response. I have old branch as well which used to show smooth scrolling with Xcode 8.3 but when I run same code with Xcode 9.0, it show choppy scrolling.

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

Scatter answered 30/10, 2017 at 7:7 Comment(3)
Can you please show me response area where you reload your table ?Snapback
Is all the data pre-fetched, or are you downloading it while the cells are getting recycled? Did you try to populate the UITableView with static data, and check if you are still observing the same lag?Southwest
Thank you all for replies. I was using one third party video recording tool and that was giving choppy effect to every scrollable view. That tool does not work well with iOS 11 so once I removed the tool and all scrollable views are smooth as before.Scatter
E
3

We found a workaround for this issue! If you simply implement

-[UITableView tableView:estimatedHeightForRowAtIndexPath:]

and return your

-[UITableView tableView:heightForRowAtIndexPath:]

everything will work.

Update: It turns out the core of the issue is that when you allocate a new UITableView with Xcode 8, the default value for UITableView.estimatedRowHeight is 0, whereas when you do the same with Xcode 9, the default value is -1, or UITableViewAutomaticDimension. Setting it back to 0 fixes the issue.

Envelope answered 8/11, 2017 at 16:4 Comment(0)
K
1

Set isPrefetchingEnabled of your collection view to false, OR(which solves your problem way better) use pre-fetching methods in UICollectionViewDataSourcePrefetching/UITableViewDataSourcePrefetching to get smoother and more efficient scrolling. Make any web loading there for data to be ready for when a cell needs to be created

Kimbra answered 7/11, 2017 at 21:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.