首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未调用ios11 didUpdateLocations

未调用ios11 didUpdateLocations
EN

Stack Overflow用户
提问于 2017-09-06 14:57:21
回答 4查看 1.6K关注 0票数 0

我正在使用CLLocationManager开发ios应用程序。

直到ios10,我调用了startUpdatingLocation,然后调用了didUpdateLocations,我得到了一个位置信息。

现在,我更新了iOS11 beta9和Xcode beta6。我调用了startUpdatingLocation,但没有调用didUpdateLocations。所以我找不到任何位置。

位置是我的应用程序的核心信息。有没有人有同样的问题?或者可以解决这个问题?对不起,我的英语很差。谢谢。

EN

回答 4

Stack Overflow用户

发布于 2017-09-06 15:04:38

在iOS 11中在info.plist中添加了新的私钥,你应该添加其中的任何一个,希望info.plist中的添加对你有用。

代码语言:javascript
复制
/*
*      Either the NSLocationAlwaysAndWhenInUseUsageDescription key or both the
*      NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription
*      keys must be specified in your Info.plist; otherwise, this method will do
*      nothing, as your app will be assumed not to support Always authorization.
*/
票数 2
EN

Stack Overflow用户

发布于 2020-12-12 01:29:27

如果您在模拟器上运行,请确保模拟器将位置设置为自定义位置。默认情况下,它是select none。你可以在模拟器-> features -> locations上找到它,它为我工作。

票数 1
EN

Stack Overflow用户

发布于 2017-09-06 17:57:59

在Info.plsit中添加

代码语言:javascript
复制
privacy - location usage description
Privacy - Location When In Use Usage Description
Application NSLocationAlwaysUsageDescription

代码语言:javascript
复制
   func CheckLocationAuthorization()  {
    if CLLocationManager.locationServicesEnabled() {
        switch CLLocationManager.authorizationStatus() {
        case .notDetermined, .restricted, .denied:
            self.ShowLocationError()
        case .authorizedAlways, .authorizedWhenInUse:
            // Do stuff
        }
    } else {
        self.ShowLocationError()
    }
}

//MARK:Show location error
func ShowLocationError()   {
    _ = UIAlertController.showAlertInViewController(viewController: self, withTitle: kAlertTitle, message: "Please allow location for getting the current weather report", cancelButtonTitle: "Setting", destructiveButtonTitle: nil, otherButtonTitles: nil, tapBlock: { (a, b, c) in
        if let url = URL(string:UIApplication.openSettingsURLString) {
            UIApplication.shared.open(url)
        }
    })
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46068725

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档