2010-01-05 4 views
2

나는 시뮬레이터에서 원하는 정확도를 확인하고 싶지만 didupdatetolocation 메서드 내에서 결코 얻지 못한다. 나는 시뮬레이터 위임 메서드가 한 번만 호출된다는 것을 안다. 누군가 시뮬레이터에서 원하는 정확도를 얻는 방법을 알고있다. 여기에 원하는 코드가있다. 정확성.시뮬레이터의 코어 위치에서 원하는 정확도를 얻는 방법?

// 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 
관련 문제