Whenever a new view controller is presented, there are delays for the user, both in waiting for views to get set up on the main thread, as well as for new data to get fetched from the server. With a little trick, you can reduce those delays by 75ms. It may not seem huge, but 75ms can have a big impact on user engagement. This post is inspired by instant.page, which does roughly the same thing but for websites.
Introduction
It’s simple: when you have a UIButton that triggers a transition to a new view controller, you set the new VC up on touchDown, not touchUpInside. Roughly speaking, you go from:
to:
75ms is the average delay I found between the two events (the range was about 50–100ms).
In Depth
Here’s the full code:
This code ensures that once the user presses down on the button, the new view controller will eventually be presented no matter what, which can reduce bugs. Your requirements may vary.
Conclusion
Although the actual work being done remains the same, the user will perceive it as occurring more quickly because it gets done further in advance. This will make your app feel more responsive!