I have a tableView , each cell in table view has a MKMapView as a subView ,and when i construct a cell , i need to add lot of overlay to the map view (based on gps points) . now , i do all the work in main thread , but when the tableview is scrolling , because there is alot of calculation and addOverlay , so the performance is too bad , How to improve this kind of problem?thex
Asked
Active
Viewed 618 times
3
-
Use GCD for load map in cell. – Toseef Khilji Oct 09 '13 at 09:24
-
Yup, do not load data into your cells on the mainthread. You should use a background thread to do the loading of the data, the calculations and filling of the cells (/overlay). To prevent the user from wondering what is going on, you should use placeholders for each bit of information that needs to be loaded. – Totumus Maximus Oct 09 '13 at 09:39
-
1Hi, now ,i use gcd for creating cells ,but i found i have to put the MapKit API : addOverlays to main thread ,otherwise , app will crash, and because i got several hundred overlays to add(i use addOverlays NOT addOverlay already) in each cell , so the scrolling is still very lag , and the logs shows that ,when i add 300 overlays is need about 1.5 second to execute the [mapView addOverlays:overlays], can i short the time addOverlays cost? – ximmyxiao Oct 10 '13 at 06:25
-
and in debugging ,i found [mapView addOverlays:overlays] will call mapView:(MKMapView *)mapView viewForOverlay:(id
)overlay hundred times,i thinks these may cause the problem , but how to do with it ? – ximmyxiao Oct 10 '13 at 06:47 -
@ximmyxiao currently, I am also facing same issue for loading thousands of overlays to mapview, what is the solution you found for this, can you share here, it would help for us also. Thanks! – Anilkumar iOS - ReactNative Mar 20 '18 at 18:43
-
Please check this, https://stackoverflow.com/questions/49360012/mapview-getting-freezing-for-few-seconds-while-loading-thousands-of-data-and-zoo I am also facing same kind issue, can you please post the answer if you would found for your issue? – Anilkumar iOS - ReactNative Mar 20 '18 at 18:44