我在应用程序中添加了mapkit。我已经将Mkmapview连接到Iboutlet的ViewController,它在模拟器中运行良好,但它在我的设备中崩溃了
[logMessagelogging] 6.1无法检索carrierName。cterror:domain-2,code-5,errstr:((OS/kern(失败(。
我正在从cllocationmanager中获取用户的位置,并尝试在地图中添加注释。代码如下:
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let userLocation:CLLocation = locations[0] as CLLocation
let coordinate = CLLocationCoordinate2D(latitude: userLocation.coordinate.latitude, longitude: userLocation.coordinate.longitude)
MD_myCurrentLocation = coordinate
setupLocationMarker(coordinate:coordinate)
manager.stopUpdatingLocation()
}
func setUplocationmarker(坐标:cllocation coortion2d({
iosMap.removeAnnotations(iosMap.annotations)
let span = MKCoordinateSpanMake(0.01, 0.01)
let region = MKCoordinateRegion(center: coordinate, span: span)
iosMap.setRegion(region, animated: true)
let annotation = MKPointAnnotation()
annotation.coordinate = coordinate
iosMap.addAnnotation(annotation)
}
尝试通过转到>>设置>>常规>>重置网络设置来重置设备的网络配置。
或
在Appdelegate中导入Coretelephony
希望这会有所帮助。