Increase the responsiveness of your UITableViews

Let’s say you have an UITableView in which rows, when touched, changes the display to another view with an animation.

If you touch quickly a row, the row will highlight just before the animation starts.

If the action performed when touching the row takes some time (let’s say more than 0.5 seconds), after having touched the row, nothing will be visible while your code is running then the row will highlight and the animation will happen.

To make the row highlight immediately, so the user has a immediate feedback on its action, do this:

Change the name of your method
– (void)tableView:(UITableView *)_tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

to

– (void) didSelectRowAtIndexPath:(NSIndexPath *)indexPath

And add this method to your view controller:


- (void)tableView:(UITableView *)_tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
  [self performSelector:@selector(didSelectRowAtIndexPath:) withObject:indexPath afterDelay:0.1f];
}

The feedback when touching a row is immediate and will greatly improve the subjective responsiveness of your application (IMHO).

(via the Instapaper blog)

4 réflexions au sujet de “Increase the responsiveness of your UITableViews”

  1. Using any of the performSelector: family of messages is a great way to improve the UI, and the usage patterns are very similar to those of « setTimeout() » in JavaScript: you order your code to *yield*, so other things can happen in the meantime.
    Thanks for the tip!

  2. Thank you for posting this! Have tried 7 ways till Sunday to get immediate highlighting. Great to know this general solution.

Laisser un commentaire