1.appDelegate中加入#import<CoreLocation/CoreLocation.h>
2. <CLLocationManagerDelegate>{CLLocationManager*locationManager;}
3.加入
if(locationManager==nil) {
locationManager= [[CLLocationManageralloc]init];
locationManager.delegate=self;
locationManager.distanceFilter=500;//定位 频率
if([[[UIDevicecurrentDevice]systemVersion]doubleValue]>=8.0) {
[locationManagerrequestAlwaysAuthorization];
}else
[locationManagerrequestWhenInUseAuthorization];
}
[locationManager startUpdatingLocation];