加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift – 错误的位置 – 位于旧金山而不是法国

发布时间:2020-12-14 04:51:37 所属栏目:百科 来源:网络整理
导读:我在法国,当我尝试新的func locationManager功能时,我的地图视图在旧金山找到我.任何的想法? override func viewDidLoad() { super.viewDidLoad() if (CLLocationManager.locationServicesEnabled()) { locationManager = CLLocationManager() locationMana
我在法国,当我尝试新的func locationManager功能时,我的地图视图在旧金山找到我.任何的想法?

override func viewDidLoad() {
    super.viewDidLoad()   

    if (CLLocationManager.locationServicesEnabled())
    {
        locationManager = CLLocationManager()
        locationManager.delegate = self
        locationManager.desiredAccuracy = kCLLocationAccuracyBest
        locationManager.distanceFilter = kCLDistanceFilterNone
        locationManager.requestAlwaysAuthorization()
        locationManager.startUpdatingLocation()
    }
}

func locationManager(manager: CLLocationManager!,didUpdateLocations locations: [AnyObject]!) {
    let location = locations[locations.count-1] as CLLocation

    let center = CLLocationCoordinate2D(latitude: location.coordinate.latitude,longitude: location.coordinate.longitude)
    let region = MKCoordinateRegion(center: center,span: MKCoordinateSpan(latitudeDelta: 0.01,longitudeDelta: 0.01))

    self.map.setRegion(region,animated: true)
}

我正在使用模拟器.

解决方法

iOS模拟器默认为美国 – San Fran,并不会估计您Mac的实际位置.

但是,您可以模拟移动甚至是特定位置,如下所示:

在Simulator的Debug菜单下,最后一个条目是“Location”;这为您提供了一个子菜单:

>没有
>自定义位置
> Apple商店
> Apple
>城市自行车骑行
>城市奔跑
>高速公路驾驶
>自定义位置可让您输入纬度/经度值.

骑自行车,城市奔跑和高速公路驾驶模拟移动位置(当然在库比蒂诺).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读