定位服务在 iOS 8 中不起作用 [英] Location Services not working in iOS 8

查看:29
本文介绍了定位服务在 iOS 8 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 iOS 7 上运行良好的应用程序不适用于 iOS 8 SDK.

My app that worked fine on iOS 7 doesn't work with the iOS 8 SDK.

CLLocationManager 不返回位置,我也没有在 Settings -> Location Services 下看到我的应用.我对这个问题进行了谷歌搜索,但没有任何结果.可能有什么问题?

CLLocationManager doesn't return a location, and I don't see my app under Settings -> Location Services either. I did a Google search on the issue, but nothing came up. What could be wrong?

推荐答案

我最终解决了自己的问题.

I ended up solving my own problem.

显然在 iOS 8 SDK 中,requestAlwaysAuthorization(用于后台定位)或 requestWhenInUseAuthorization(仅在前台定位)调用 CLLocationManager 之前需要开始位置更新.

Apparently in iOS 8 SDK, requestAlwaysAuthorization (for background location) or requestWhenInUseAuthorization (location only when foreground) call on CLLocationManager is needed before starting location updates.

Info.plist 中还需要有 NSLocationAlwaysUsageDescriptionNSLocationWhenInUseUsageDescription 键,并在提示中显示一条消息.添加这些解决了我的问题.

There also needs to be NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key in Info.plist with a message to be displayed in the prompt. Adding these solved my problem.

有关更多信息,请查看:Core-Location-Manager-Changes-in-ios-8

For more extensive information, have a look at: Core-Location-Manager-Changes-in-ios-8

这篇关于定位服务在 iOS 8 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆