swift怎么用CLlocation获取当前定位信息

我的核心代码如下

    let latDelta = 0.05
    let longDelta = 0.05
    let currentLocationSpan:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, longDelta)
    let center:CLLocation = CLLocation(latitude: 32.029171, longitude: 118.788231)
    let currentRegion:MKCoordinateRegion = MKCoordinateRegion(center: center.coordinate,span: currentLocationSpan)
    
    self.mainMapView.setRegion(currentRegion, animated: true)
    

其中这一行规定了初始化的定位点
let center:CLLocation = CLLocation(latitude: 32.029171, longitude: 118.788231)

现在我想让它获取我当前的位置信息 然后可以实时更新 要怎么修改?

阅读 2.7k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题