Search code examples
uitableviewuisearchdisplaycontroller

UISearchDisplayController long delay before becoming active


I have a table view with UISearchDisplayController. When I click in the search bar for the first time since launching the app, the search interface animates and becomes active almost immediately, as you would expect. However, on subsequent searches, there is a delay that gets longer and longer before the animation occurs and the search interface is displayed. After a while, there is a 2-3 second pause when you click inside the search bar before the animation.

I assume this is some kind of memory issue but I can't track it down. Any suggestions?


Solution

  • I'm pretty sure I fixed the issue and it was of course a memory issue. This is just a reminder to never do disk or networking related tasks on the main thread during cellForRowAtIndexPath. I was fetching a (very small) image and using it to set the backgroundColor of a cell. Not a good idea. I switched to using GCD and it seems to work fine.