2010-01-05 43 views
2

我想在模擬器中檢查所需的準確性,但我從來沒有得到它在didupdatetolocation method.I知道在模擬器委託方法只被稱爲一次。有人知道如何獲得所需的準確性在模擬器。這裏是我的代碼,以獲得所需準確性。如何獲得期望從模擬器核心位置的準確性?

// Delegate method from the CLLocationManagerDelegate protocol. 
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 
    NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow]; 
    if (locationAge > 5.0) 
    { 
     self.DeviceOldLocation=newLocation; 
     return; 
    } 
    LatitudeData = [[[[NSString alloc] initWithFormat:@"%f",newLocation.coordinate.latitude] retain]autorelease]; 
    LongitudeData =[[[[NSString alloc] initWithFormat:@"%f",newLocation.coordinate.longitude] retain]autorelease]; 

    if (newLocation.horizontalAccuracy < 0) 
     return; 

    if (bestEffortAtLocation == nil || bestEffortAtLocation.horizontalAccuracy < newLocation.horizontalAccuracy) 
    { 
     // store the location as the "best effort" 
     self.bestEffortAtLocation = newLocation; 
     [self insertNewLocationInDataBase]; 
     if (newLocation.horizontalAccuracy <= Accuracy) 
     { 
      self.VeryAccuratelocation=newLocation; 
      BestLocationAcquired=YES; 
      [self insertNewLocationInDataBase]; 
      [self stopUpdatingLocation];     
      UIAlertView *BestLocation=[[UIAlertView alloc] initWithTitle:@"Best Location" message:@"best location found" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil]; 
      [BestLocation show]; 
      [BestLocation release]; 
     } 
    } 
} 

回答

3

模擬器位置管理器始終以相同的精度返回相同的位置。因此,您應該在瞄準模擬器時調整準確度閾值,或者僅在真實設備上測試位置服務。

#if TARGET_IPHONE_SIMULATOR 
    double Accuracy = 100; 
#else 
    double Accuracy = 5; 
#endif 
相關問題