swiftのmap上で現在位置を表示したいと思っています。しかしなぜかあの青い丸が表示されません。
mapのUser Locationにもチェックしてあります。CoreLocationFrameworkも追加済。
mac本体の位置情報サービスのしようもオンになっています。本当に何故かわからないので教えて頂けたら幸いです。
FirstViewController
1import UIKit 2import MapKit 3import CoreLocation 4 5class FirstViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate { 6 7 let locationManager = CLLocationManager() 8 9 @IBOutlet weak var mapView: MKMapView! 10 11 override func viewDidLoad() { 12 super.viewDidLoad() 13 14 self.locationManager.delegate = self 15 16 self.locationManager.desiredAccuracy = kCLLocationAccuracyBest 17 18 self.locationManager.distanceFilter = kCLDistanceFilterNone 19 20 self.locationManager.requestWhenInUseAuthorization() 21 //※info.plistに「Privacy - Location When In Use Usage Description」を追加済 22 23 self.mapView.showsUserLocation = true 24 25 self.mapView.delegate = self 26 27 self.locationManager.startUpdatingHeading() 28 29 } 30 31 override func didReceiveMemoryWarning() { 32 super.didReceiveMemoryWarning() 33 // Dispose of any resources that can be recreated. 34 } 35 36}
回答3件
あなたの回答
tips
プレビュー