我正在学习如何使用新的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()
}
}
}
Run Code Online (Sandbox Code Playgroud)
请你帮助我好吗?