我正在开发一个简单的应用程序,它会每秒找到一个人的坐标和高度,它会在屏幕上显示。寻找坐标很简单,但我搜索了互联网,关于海拔的一切都非常复杂,需要许多不同的功能。
这是我到目前为止所拥有的。我正在使用“单一视图”格式。
CLLocationManager *locationManager;
- (NSString *)deviceLocation {
return [NSString stringWithFormat:@"latitude: %f longitude: %f", locationManager.location.coordinate.latitude, locationManager.location.coordinate.longitude];
}
- (void)viewDidLoad
{
locationManager = [[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m
[locationManager startUpdatingLocation];
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timer) userInfo:nil repeats:YES];
[super viewDidLoad];
}
-(void)timer
{
NSLog(@"%@", [self deviceLocation]);
coordinates.text = [self deviceLocation];
altitude.text = ;\\altitude goes here
}