再配置後工程後做如下幾件事:
一、在plist中加兩句(如圖一):
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
二、在UserLocationViewController中加三句(如圖二):
locationManager =[[CLLocationManager alloc] init];
[locationManager requestAlwaysAuthorization];//用這個方法,plist中需要NSLocationAlwaysUsageDescription
[locationManager requestWhenInUseAuthorization];//用這個方法,plist裏要加字段NSLocationWhenInUseUsageDescription
圖二:
三、獲得經緯度: