1,在info.plst中设置以下键值:
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription
2,导入CoreLocation库
3,代理CLLocationManagerDelegate,代码:
if CLLocationManager.locationServicesEnabled()
{
let manger = CLLocationManager()
manger.startUpdatingHeading()
manager.startUpdatingLocation()
}
网友评论