// 定位的头文件
import "CCLocationManager.h"
需要遵守的代理 <CLLocationManagerDelegate>
[UIApplication sharedApplication].idleTimerDisabled=YES;不自动锁屏
[UIApplication sharedApplication].idleTimerDisabled=NO;自动锁屏
CLLocationManager *locationmanager = [[CLLocationManager alloc] init];
[locationmanager requestAlwaysAuthorization];
[locationmanager requestWhenInUseAuthorization];
locationmanager.delegate = self;
// 2.0 获得经纬度
[[CCLocationManager shareLocation] getLocationCoordinate:^(CLLocationCoordinate2D locationCorrrdinate) {
NSString *lngStr = [NSString stringWithFormat:@"%f", locationCorrrdinate.longitude];
NSString *latStr = [NSString stringWithFormat:@"%f", locationCorrrdinate.latitude];
if (lngStr.length > 0 && latStr.length > 0) {
[NSUSERDEFAULTS setValue:lngStr forKey:kLongitude];
[NSUSERDEFAULTS setValue:latStr forKey:kLatitude];
[self getLocationForNetWithLng:lngStr AndLat:latStr];
}
}];