iOS 4.2.1上的Wifi三角测量和不同iOS模拟器上的当前位置

时间:2012-03-15 18:56:38

标签: iphone ipod triangulation

我有iPod Touch 2G,iOS 4.2.1,我无法在iOS 3.2软件更新后确定设备的位置(使用Wifi三角测量)。 我的代码:

-(IBAction) naitapraeguneasukoht: (id) sender 
{
     CLLocation*location=[[CLLocation alloc] initWithLatitude:57.797944 longitude:25.04858];
     MKCoordinateRegion region = {{0.0f, 0.0f}, {0.0f, 0.0f}};
     region.center = location.coordinate;
     region.span.longitudeDelta = 1.0f;
     region.span.latitudeDelta = 3.8f;

     [self.mapView setRegion:region animated:YES];
     [location release];

     self.locationManager = [[[CLLocationManager alloc] init] autorelease];
     locationManager.delegate = self;
     locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
     [locationManager startUpdatingLocation];
}

- (void) locationManager: (CLLocationManager *) manager didFailWithError: (NSError *) error 
{
    NSString *teade = [[NSString alloc] initWithString:@"Ei õnnestunud asukohta tuvastada"];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:trade delegate:nil cancelButtonTitle: @"OK" otherButtonTitles:nil];
    [alert show];
    [teade release];
    [alert release];
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{
    MKCoordinateRegion region;
    MKCoordinateSpan span;
    span.latitudeDelta=0.005f;
    span.longitudeDelta=0.005f;
    region.center=newLocation.coordinate;
    region.span=span;
    [mapView setRegion:region animated:TRUE];
}

我收到一条错误消息,指出无法确定位置。定位服务肯定是开启的。

iOS 4.2模拟器给了我正确的位置,但iOS 5.0模拟器给了我Cupertino。为什么会这样,为什么它不能在我的设备上运行?

0 个答案:

没有答案