IPhone : Preloading views of unshown UITableViewControllers using Grand Central Dispatch

on Sunday, April 19, 2015

I am trying to use the library ICViewPager , which allows me to create sliding tabs with a UIPageViewController. (As I scroll through pages, the tabs also move. Or I press on the tab, I will be "scrolled" to the corresponding page.)


In my app, each page in the UIPageViewController is a UITableViewController that contains 30-60 UILabels. I found the scrolling between the pages not fluid enough.


What I have tried to solve the problem is that I allocate the surrounding UITableViewControllers in advance. That is, if the user presses on tab #7, I instantiate UITableViewControllers #5, #6, #8 and #9 from the storyboard, and store them in an NSMutableArray. And if the user needs them I retrieve them from the array.


But this does not help. And I suspect that I should also preload the views inside those UITableViewControllers.


I think I can wrap the code for preloading the views and put them in a block, and then add/dispatch (dispatch_async) that block to a custom concurrent queue using GCD.


I read from this StackOverflow question that to preload views, I can just call [myTableViewController view]. Do I need to store the preloaded view anywhere? Or just call it?


More importantly, can the jerky paging be solved by preloading views using GCD?


0 comments:

Post a Comment