在不显示提示信息的情况下,如何获取用户当前位置的经纬度

Posted

技术标签:

【中文标题】在不显示提示信息的情况下,如何获取用户当前位置的经纬度【英文标题】:without displaying the alert message,how to get the user current locatation latitude and longitude 【发布时间】:2013-08-24 12:54:33 【问题描述】:

我的客户要求在显示用户当前位置以及如何在地图视图上获取用户纬度和经度时不需要显示警报消息。

任何人都请帮助我,不要在地图视图上显示警报消息,我们如何获得纬度和经度。

- (void)viewDidLoad

    [super viewDidLoad];

    locationManager = [[CLLocationManager alloc]init];
    //display current location
    [self.mapview setShowsUserLocation:YES];

     //get the current location latitude and algitude
    NSString *lati = [NSString stringWithFormat:@"%f",locationManager.location.coordinate.latitude];
    NSString *lang = [NSString stringWithFormat:@"%f",locationManager.location.coordinate.longitude];
    NSLog(@"lati  : %@",lati);
    NSLog(@"langi  : %@",lang);

【问题讨论】:

【参考方案1】:

你不能。这是 ios 内置的隐私考虑。当您首次请求访问位置数据时,会自动显示警报。您不应该想破坏这种隐私管理。

【讨论】:

以上是关于在不显示提示信息的情况下,如何获取用户当前位置的经纬度的主要内容,如果未能解决你的问题,请参考以下文章