Load MKMapView in UITableViewCell quickly

I'm only a relatively new iPhone programmer so hopefully this makes sense.

I've created a UITableView in a storyboard and it is displaying correctly. I have created two different types of prototype table view cells. One is just a simple cell displaying text using the "Left Detail" style while the other contains an MKMapView and a toolbar. I create a single instance of the map an all the rest of the cells are the simple text cells.

The problem I am having is that when the table view is initially displayed, the UITableViewCell containing the map is off-screen. When I scroll down, the UI pauses while the cell is loaded. Based on Instruments, it seems that the time is spent in [MKMapView initWithCoder] but I don't know of any way to load the prototype cell before dequeuing it.

Previously the map cell was above-the-fold so was loaded before I did any scrolling. Now that I have rearranged things, it is loading later and causing a delay.

Is there any way that I can pre-load the UITableViewCell containing the MKMapView, or put some of the loading of the MKMapView into the background?


You can preload the MKMapView view instance before, add it as subview to the cell in the cellForRowAtIndexPath method. That way the map view have some time to load before the cell is displayed.

Other way of doing it would be using MKMapSnapshotter, do a background fetch and cache the result. Please check out this answer https://stackoverflow.com/a/39479479/384288, maybe it will help someone.

Need Your Help

Android Activity/Intent vs. Qt Signal/Slot vs. iPhone ?/?

iphone android qt android-intent signals-slots

I'm trying to investigate similarities of communication between objects/components on different mobile platforms.