用的是第三方MMLocationManager.h 和.m
用的时候就一个方法。。。
-(void)getLat
{
__block__weakTestViewController *wself = self;
[[MMLocationManager shareLocation] getLocationCoordinate:^(CLLocationCoordinate2D locationCorrrdinate) {
[wself setLabelText:[NSString stringWithFormat:@"%f %f",locationCorrrdinate.latitude,locationCorrrdinate.longitude]];
}];
}
另外如果想获取城市名什么的要下面的方法就OK
-(void)getCity
{
__block__weakTestViewController *wself = self;
[[MMLocationManager shareLocation] getCity:^(NSString *cityString) {
[wself setLabelText:cityString];
}];
}
-(void)getAddress
{
__block__weakTestViewController *wself = self;
[[MMLocationManager shareLocation] getAddress:^(NSString *addressString) {
[wself setLabelText:addressString];
}];
}
-(void)getAllInfo
{
__block NSString *string;
__block__weakTestViewController *wself = self;
[[MMLocationManager shareLocation] getLocationCoordinate:^(CLLocationCoordinate2D locationCorrrdinate) {
string = [NSString stringWithFormat:@"%f %f",locationCorrrdinate.latitude,locationCorrrdinate.longitude];
} withAddress:^(NSString *addressString) {
string = [NSString stringWithFormat:@"%@\n%@",string,addressString];
[wself setLabelText:string];
}];
}