简体   繁体   中英

How to prevent MKMapView from loading content?

I have an app where you can search for some places either using online api or by downloading the database with all data (name of the place, latitude, longitude, etc). If internet is present, i use online api and show the map. If there is no internet, i use database, but still show the map, because there is a chance that some portion of map is still cached. Now I'm trying to add a toggle to switch between online and offline mode, and I want to make sure that my app is not using any cell/wifi data while it is in offline mode.

I would like to be able to prevent the MKMapView in my app from loading the tiles from web, but show only cached content even when the internet connection is present. Is there a way to do that?

I was looking for this answer myself today and my best answer is that you will need to remove the MKMapView. Setting the view to hide it self(hidden =true) will not prevent downloading tiles.

[mapView removeFromSuperview];

Or just don't add it in the first place and add it when the user has internet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM