如何在iphone4.0中查找纬度和经度?
我不熟悉iphone 通过使用CLLocation,我可以找到纬度和经度,但它在iPhoneSimulaer4.0中不起作用在3.2.1中起作用,请任何人告诉我如何在iphone4.0中计算纬度和经度。如何在iphone4.0中查找纬度和经度?,iphone,Iphone,我不熟悉iphone 通过使用CLLocation,我可以找到纬度和经度,但它在iPhoneSimulaer4.0中不起作用在3.2.1中起作用,请任何人告诉我如何在iphone4.0中计算纬度和经度。 提前感谢位置仅在真实设备上显示。您可能会发现CLLocationManager中的值将在模拟器中工作(可能来自您的交换-尽管它不会非常准确),但地图上的蓝针将始终位于CA 这个概念直接在你的应用程序中使用,并检查你的纬度和长度 CLLocationCoordinate2D location =
提前感谢位置仅在真实设备上显示。您可能会发现
CLLocationManager
中的值将在模拟器中工作(可能来自您的交换-尽管它不会非常准确),但地图上的蓝针将始终位于CA 这个概念直接在你的应用程序中使用,并检查你的纬度和长度
CLLocationCoordinate2D location =
[[[mapview userLocation] location] coordinate];
//NSLog(@"Location found from Map: %f %f",
location.latitude,location.longitude);
#pragma mark locationManager delegate
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
//if the time interval returned from core location is more than two minutes we ignore it because it might be from an old session
if(abs([newLocation.timestamp timeIntervalSinceDate: [NSDate date]]) < 120)
{
//CLLocation *test = [[CLLocation alloc] initWithLatitude:-33.857034 longitude:151.035929];
currentLocation = newLocation;
coordinates = newLocation.coordinate;
latitude = currentLocation.coordinate.latitude;
longitude = currentLocation.coordinate.longitude;
[locationManager stopUpdatingLocation];
}
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"%@", [error description]);
}
#pragma标记位置管理器代表
-(void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation
{
//如果从核心位置返回的时间间隔超过两分钟,我们将忽略它,因为它可能来自旧会话
if(abs([newLocation.timestamp timeintervalncencedate:[NSDate date]])<120)
{
//CLLocation*test=[[CLLocation alloc]INITWITH纬度:-33.857034经度:151.035929];
当前位置=新位置;
坐标=newLocation.coordinate;
纬度=当前位置。坐标。纬度;
经度=当前位置。坐标。经度;
[locationManager停止更新位置];
}
}
-(无效)locationManager:(CLLocationManager*)manager错误:(N错误*)错误
{
NSLog(@“%@,[错误描述]);
}
在真实设备上测试,而不是在模拟器上测试。如果您的代码不起作用,您需要显示它。谢谢,我可以获取默认位置,但它在device4.0中不起作用。如何在iphone device4.0中实现这一点。您的应用程序是否因位置服务而被阻止?在iPhone上:设置->常规->定位服务->为你的应用打开。此外,可能值得测试你的GPS设备是否有故障。打开地图应用程序并按下位置按钮(左下角)。如果它在上面找到你的位置,你就知道你的手机很好!