Built-In Tools

I really believe that most people reading this story know about this, but some people, even after using these tools, are not using it in the right way.

  • Reuse cell instances: for specific type of cell you should have only one instance, no more.
  • Don’t bind data at cellForRowAtIndexPath: method ‘cause at this time cell is not displayed yet. Instead use tableView:willDisplayCell:forRowAtIndexPath: method in the delegate of UITableView.
  • Calculate further cell heights faster. It’s routine process for engineers, but you will be awarded for your patience by increased smooth scrolling on sets of complex cells.

We need to go deeper

Of course, mentioned points are not enough to implement really smooth scrolling, and especially it becoming noticeable when you have task to implement complex cell with lots of gradients, views, interactive elements, some decorative elements and more.

  • Reduce areas where iOS performs useless blending: don’t use transparent backgrounds, check this out using iOS Simulator or Instruments; gradient will be done better without blending if you can do this.
  • Perform code optimizations to achieve balance of loading CPU & GPU. You should clearly know which part of rendering must be done by GPU, and which one — by CPU for keeping balance.
  • Write specific code for specific cell types.

Pixel hunting

Do you know how pixels look? I mean, how look physical pixels in screen? I sure you know but I will show you:

  • Perform rounding of all pixel-relating data: point coordinates, heights/widths of UIViews and many others.
  • Track your graphical resources: images must be pixel-perfect, else when they will be rendered on Retina displays, it will be doing with unnecessary antialiasing.
  • Periodically recheck your situation with this problem ‘cause it can changes very quickly.

Asynchronous UI

Probably it will be look little bit strange, but it’s very effective way to make UITableView scrolling more smoothly if you know what you’re doing.

  • Find render bottlenecks which don’t allow you to return cells very fast.
  • Move operations to background thread and refresh displayed content on the main thread.
  • Last resort is setting up your CALayers for asynchronous displaying mode (even if they are about simple text or images) — this will help you to increase FPS.

Results

I’ve tried to explain main ideas of iOS drawing system (without using of OpenGL ‘cause it’s more rare cases). Of course some of this seems blurred, but in fact there’s only directions where you should research your code to find all troubles with scroll performance.

--

--

--

Stories and technical tips about building apps for iOS, Apple Watch, and iPad/iPhone

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alexander Orlov

Alexander Orlov

CEO @ Starling, Inc. | http://starling.audio

More from Medium

Tuist Your Circle — Building A Project Faster With CircleCI — Part 2

What is the Variables and Constants in Swift Language ?

ITMS-90165 error

ITMS-90165 error

Fastlane TestFlight app distribution without 2FA