您好,我正在开发一个 iOS 应用程序。我想使用 GPS 获取设备的当前位置。我怎样才能得到一个地方的纬度和经度,我怎样才能从中确定当前的城市名称。我从以下 http://www.appcoda.com/how-to-get-current-location-iphone-user/ 中遇到了示例但是当我按下按钮时什么也没发生。我正在使用 IOS 模拟器并且我已经将 Debug --> Location --> 更改为 Apple。
我正在为 ios 8.0 开发
最佳答案
在 iOS 8 中,苹果更改了一些 plist 键和位置访问条目..
请按照以下步骤保持您的核心工作..
- NSLocationAlwaysUsageDescription
- NSLocationWhenInUseUsageDescription See Apple document for plist.
- 在
startUpdatingLocation
之前和分配CLLocationManager
之后添加位置服务权限代码
if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
{
[locationManager requestAlwaysAuthorization];
}
关于ios - 在ios8.0 App中从GPS获取位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29648742/