问它自我解释的细节,但我仍然解释了这个问题。为什么我无法在模拟器中获取位置?
我是新来获取当前应用程序的位置。我已经构建了一个应用程序,可以在文本视图中为我提供当前位置。
但是,当我运行该应用程序到xcode 4.0,我看不到任何位置要获取。
正如我提到的很多例子,我是正确的编码。但现在我想知道的是iPhone模拟器能够获取当前位置?
问它自我解释的细节,但我仍然解释了这个问题。为什么我无法在模拟器中获取位置?
我是新来获取当前应用程序的位置。我已经构建了一个应用程序,可以在文本视图中为我提供当前位置。
但是,当我运行该应用程序到xcode 4.0,我看不到任何位置要获取。
正如我提到的很多例子,我是正确的编码。但现在我想知道的是iPhone模拟器能够获取当前位置?
在iPhone模拟器不给currentlocation.But它应该在Device.So尝试它在设备上。
以下代码将允许向您显示用户的当前位置;
[mapView setShowsUserLocation:YES];
如果您尝试设备当前的经纬度将返回,但如果您尝试在模拟器纬度= 0和经度= 0将返回。因为用户的经度和纬度是从iPhone中的设备返回的,但不在模拟器中。所以你最好在设备上试试它。
是的,谢谢。我得到了Sollution为什么我没有得到位置。谢谢。 –
`鉴于没有负载
locationManager=[[CLLocationManager alloc] init];
locationManager.delegate=self;
appDelegate.IsFromRefreshPosition=YES;
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
if ([CLLocationManager locationServicesEnabled])
{
[locationManager startUpdatingLocation];
}
geocoarder returns the plackmark of current location
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
currentLocation = newLocation;
[currentLocation retain];
[locationManager stopUpdatingLocation];
NSLog(@"%f %f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);
geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:currentLocation.coordinate];
[geocoder setDelegate:self];
[geocoder start];
}
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"locationManager:%@ didFailWithError:%@", manager, error);
}
-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder1 didFindPlacemark:(MKPlacemark *)placemark
{
NSLog(@"The geocoder has returned: %@",[placemark addressDictionary]);
NSLog(@"CountryName :",[[placemark addressDictionary] objectForKey:@"Country"]);
NSLog(@"cityName :",[[placemark addressDictionary] objectForKey:@"City"]);
NSLog(@"After SubLocality %@",Addressstr);
}
}
-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder1 didFailWithError:(NSError *)error
{
NSLog(@"reverseGeocoder:%@ didFailWithError:%@", geocoder, error);
}
其工作设备我都没
确定。谢谢。我尝试了很多,但没有获得经纬度。现在我开始知道iPhone模拟器不会为它工作。谢谢。 –