简体   繁体   中英

MapKit Internet Issue

I am back and have a question on map-kit and the internet connection. I have a app which tracks the user but when i turn off cellular data and wifi its tracks the user and shows the wrong distance. I want to turn off maps if there are no internet and when there is internet turn on the maps. Thank You in Advance.

Take a look at Apple's reachability project that tests Internet reachability, and just implement it in your app to hide/show the map.

This is also a good step-by-step tutorial

The great thing about this is that it works with notifications, so you can react to changes in the network and not only to whether the network was available at the start of the application.

Once you include it in your project it can be as simple as:

Reachability *reach = [Reachability reachabilityForInternetConnection];   
NetworkStatus status = [networkReachability currentReachabilityStatus];    
if (status == NotReachable) {        
    // hide map        
} else {        
    // show map
}        

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