ios - locationManager 在 Swift 3 中被弃用了吗?

标签 ios xcode core-location swift3 ios10

我已经下载了最新版本的 XCode 来测试我在 iOs 10 Beta 中的项目。当我打开它时,XCode 询问我是否要将我的项目转换为 Swift 3。这样做之后,出现了一个错误:

Cannot override 'locationManager' which has been marked unavailable: APIs deprecated as of iOS 7 and earlier are unavailable in Swift

我的代码如下:

func locationManager(_ manager: CLLocationManager, didUpdateToLocation newLocation: CLLocation, fromLocation oldLocation: CLLocation) {
    locationManager.stopUpdatingLocation()

    currentUserLocation = newLocation
}

是否有另一个“未弃用”的函数来实现相同的结果?

谢谢!

最佳答案

此方法替换了您正在使用的方法:

func locationManager(_ manager: CLLocationManager, 
                     didUpdateLocations locations: [CLLocation]) {

}

了解更多 here .

关于ios - locationManager 在 Swift 3 中被弃用了吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38591381/

相关文章:

iOS 7 风格的模糊 View

xcode - Sprite Kit Swift 跳跃角色

ios - CLLocationManager 在蜂窝网络 (3G) 中无法获取位置精度

ios - 从后台任务启动 iOS 7 中的位置管理器

ios - 位置管理器错误 : The operation couldn’t be completed.(kCLErrorDomain 错误 0。)

iOS 7 套接字连接被拒绝错误 61

objective-c - 从 applicationDidEnterBackground 方法保存一些数据

ios - 在 TableViewCell 中进行更改

ios - 如何使 UIProgressView 快速工作

objective-c - cmake - 设置 - xcode 属性 - 隐式链接 objective-c 运行时支持