博客> 定位
定位
2019-12-12 05:21 评论:0 阅读:524 魔灵

pragma mark

pragma mark -- 定位

-(void)startGpsToGetAddress

{

if ([CLLocationManager locationServicesEnabled]) {

    [[UserLocation sharedUserLocation] startGetLocation];

}

else

{

    [WSProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"请允许访问您的定位服务:设置->隐私->定位服务"]];

}

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishLocation:) name:@"finishLocation" object:nil];

//failToLocation

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFailToLocation:) name:@"failToLocation" object:nil];

}

-(void)didFinishLocation:(NSNotification *)notif

{

//在回调函数里面获取 定位经纬度

if (notif.userInfo) {

    NSLog( @" -didFinishLocation------ %@ --- %@",[notif.userInfo objectForKey:@"LATITUDE"],[notif.userInfo objectForKey:@"LONGTITUDE"]);

    _indexLatitude = [notif.userInfo objectForKey:@"LATITUDE"];

    _indexLongitude = [notif.userInfo objectForKey:@"LONGTITUDE"];

    [self loadRecommondHouseData];

}

[[UserLocation sharedUserLocation]stopGetLocation];

}

-(void)didFailToLocation:(NSNotification *)notif

{

//在回调函数里面获取 定位经纬度

 [WSProgressHUD showErrorWithStatus:@"定位失败 请到设置-隐私-定位服务查看定位服务"];

}

收藏
0
sina weixin mail 回到顶部