我正在学习如何使用新的Swift语言(只有Swift,没有Objective-C).要做到这一点,我想做一个简单的视图与 map (MKMapView
).我想找到并更新用户的位置(比如在Apple Map应用程序中).
我试过了,但什么都没发生:
import MapKit
import CoreLocation
class MapView : UIViewController, CLLocationManagerDelegate {
@IBOutlet weak var map: MKMapView!
var locationManager: CLLocationManager!
override func viewDidLoad() {
super.viewDidLoad()
if (CLLocationManager.locationServicesEnabled())
{
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
}
}
}
你能帮帮我吗?