我已经下载了最新版本的 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/