【发布时间】:2012-01-07 15:54:40
【问题描述】:
我正在关注http://www.switchonthecode.com/tutorials/getting-your-location-in-an-iphone-application 教程,但我无法在我的 Xcode SDK 中获取 mi 纬度和经度。
- (void)viewDidLoad {
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
int degrees = newLocation.coordinate.latitude;
double decimal = fabs(newLocation.coordinate.latitude - degrees);
int minutes = decimal * 60;
double seconds = decimal * 3600 - minutes * 60;
NSString *lat = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
//latLabel.text = lat;
degrees = newLocation.coordinate.longitude;
decimal = fabs(newLocation.coordinate.longitude - degrees);
minutes = decimal * 60;
seconds = decimal * 3600 - minutes * 60;
NSString *longt = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
NSLog(@"%@ %@",longt, lat);
}
它不会在控制台中显示纬度和经度。 请帮帮我。
【问题讨论】:
-
你在实现委托方法
locationManager:didFailWithError:吗?如果是这样,是否有错误?如果没有,执行它,看看是否有错误。 -
代码对我来说直接有效。在单一视图应用程序中。当应用要求使用您当前的位置时,您是否点击了确定?
-
啊,我才意识到我使用的是iOS5。你得到:服务器不接受客户端注册 68. 在控制台中
-
是的,当应用要求使用您的当前位置时,我点击确定
-
你得到的是:服务器不接受控制台中的客户端注册 68
标签: objective-c ios xcode ios4