Pri*_*ine 14
从IOS 8开始,您需要在启动CLLocationManager之前请求授权.
你在调用其中一种方法吗?
[self.locationManager requestWhenInUseAuthorization]; // For foreground access
[self.locationManager requestAlwaysAuthorization]; // For background access
Run Code Online (Sandbox Code Playgroud)
如果您在XCode 6之前创建了项目,则可能还需要为新权限添加info.plist条目.
有关详细信息,请查看此帖子:位置服务在iOS 8中不起作用
小智 14
在您的方法中添加以下代码
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
{
[self.locationManager requestWhenInUseAuthorization];
}
Run Code Online (Sandbox Code Playgroud)
同时在您的info.plist文件中添加以下行
键:NSLocationWhenInUseUsageDescription 值:使用当前位置
| 归档时间: |
|
| 查看次数: |
14425 次 |
| 最近记录: |