Reputation: 7873
I have an app that uses a UITableView to layout a cards-style UI, where each cell is a card. That means that each card has a lot of subviews and a lot to draw to the screen. Using a table view means that if the user adds a lot of cards, I don't have to manage caching and memory around that.
The problem is that when the user scrolls a new card onto the screen, there's a noticeable lag as it skips some frames while it draws the new card.
I've performed optimisations, for instance I've got the drawing code down to a small size, so methods aren't being called unnecessarily. The thing I can't get past is - the view needs to draw to the screen on the main thread. So I'm kind of stuck as to what I could do to not make it lag.
Upvotes: 0
Views: 662
Reputation: 1182
UIImage resizes are expensive if you are scrolling (this affects UIButton UIImageView and anything that use UIImage internally)and create elements like buttons for each cell. But even if you have images of the right sizes and reuse the other elements if the cell is really complex you will have that lag. So the only way you can avoid that in my opinion is to move things to a background thread, you should look at AsyncDisplayKit a framework made to deal with this kind of situations and provide a really smooth scroll in almost any situation.
Upvotes: 1