我正在编写在 map 上显示我的位置的代码。
我知道该位置实际上无法在模拟器上使用,但它可以显示带有蓝色圆圈的虚假位置。
在我的 map 中,它只显示一张没有蓝色圆圈的大 map 。 为什么我会收到此错误?
(Could not retrieve region info)
它可以构建,但我在输出时收到错误,它显示:
"2019-12-11 22:07:53.809967+0100 Ecologia[8465:265293] Metal API Validation Enabled 2019-12-11 22:07:54.001955+0100 Ecologia[8465:265293] libMobileGestalt MobileGestalt.c:1647: Could not retrieve region info"
这是我的代码:
//
// ViewController.swift
// Ecologia
//
// Created by Antonio Trotta on 11/12/2019.
// Copyright © 2019 Antonio Trotta. All rights reserved.
//
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController {
@IBOutlet weak var Map: MKMapView!
let locationManager:CLLocationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
locationManager.requestWhenInUseAuthorization()
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = kCLDistanceFilterNone
locationManager.startUpdatingLocation()
Map.showsUserLocation = true
}
}
最佳答案
关于swift - 在 swift 上显示用户位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59294260/