Meh*_*tri 13
实现CLLocationManagerDelegate并编写此函数并在viewController的viewDidLoad方法中调用它.
-(void)startLocationManager
{
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate=self;
locationManager.desiredAccuracy=kCLLocationAccuracyBestForNavigation;
[locationManager startUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
CLLocationCoordinate2D coordinate = [newLocation coordinate];
double dblLatitude = coordinate.latitude;
double dblLongitude = coordinate.longitude;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4686 次 |
| 最近记录: |