I need to have few different cell types in one quite complex table view. I registered 10 xib's with those different cell classes with different reuse identifiers. The problem is that when I scroll the table view for the first time (from top to bottom) then I can see it is lagging a little bit. However after I scrolled to the bottom, then scrolling back to the top and to the bottom again runs smoothly. The problems seems to be in dequeueReusableCellWithIdentifier: which does not seem to load different xib files fast enough while scrolling if there is no reusable cell of needed type at the moment. That's why first scrolls is lagging but when enough reusable cells of each type are loaded then it starts to scroll smoothly.
Is there any way to preload reusable cells for UITableView. So for example I could load each xib type 3 times (so tableview would have 30 reusable cells already loaded in memory (3 for each of 10 cell types) when there is a call to dequeueReusableCellWithIdentifier)? I will need to publish app on the app store later so any private api is not allowed. Or maybe you have any other possible solutions to improve performance in such case?
Creating a secondary cache with preloaded cells solved the scrolling problem. On viewDidLoad I'm registering nibs (with registerNib:forCellReuseIdentifier:) and right after that also in viewDidLoad I'm creating a mutable array and I use dequeueReusableCellWithIdentifier: to load few cell's for each nib and I put those cells in my mutable array. Later in cellForRowAtIndexPath I first check if I have preloaded cell with needed type in my mutable array. If I have it there then I return this cell and remove it from array (I do not call dequeueReusableCellWithIdentifier: in this case). If I do not have it in my cache then I call dequeueReusableCellWithIdentifier: to get the cell.
EDIT: It turned out that the main reason of lag were some simple reactive cocoa bindings that I had in awakeFromNib. After removing these reactive cocoa bindings everything started to scroll smoothly even without any additional cell preloading.