2014-01-14 2 views
-1

날씨를 얻기 위해 좌표를 사용하고 있으며 정상적으로 작동합니다. 도시 이름은 UILabel에 표시됩니다. 내 아이폰에서 앱을 실행하기 전까지는 모든 것이 잘 작동하며 나타나는 도시 이름이 완전히 잘못되었습니다.IOS 시뮬레이터가 잘못된 좌표를 표시합니다.

나는 시뮬레이터가 여전히 위치를 결정할 것이라고 생각했지만 전화를 끊고 앱을 실행해도 여전히 잘못된 도시를 보여줍니다.

누구든지이 문제를 알고 있습니까? 내가 전화로 실행할 때 또는 코드와 관련 있다고 생각할 때 응용 프로그램에 영향을 미치는 시뮬레이터입니까?

편집 :

내가 사용 반응성 코코아 및 CLLocationManager

- (id)init { 
if (self = [super init]) { 
    _locationManager = [[CLLocationManager alloc] init]; 
    _locationManager.delegate = self; 

    _client = [[WXClient alloc] init]; 

    [[[[RACObserve(self, currentLocation) 
     ignore:nil] 
     // Flatten and subscribe to all 3 signals when currentLocation updates 
     flattenMap:^(CLLocation *newLocation) { 
      return [RACSignal merge:@[ 
            [self updateCurrentConditions], 
            [self updateDailyForecast], 
            [self updateHourlyForecast] 
            ]]; 
     }] deliverOn:RACScheduler.mainThreadScheduler] 
    subscribeError:^(NSError *error) { 
     [TSMessage showNotificationWithTitle:@"Fel" subtitle:@"Det gick inte att hämta vädret." 
type:TSMessageNotificationTypeError]; 
    }]; 
} 
return self; 
} 

- (void)findCurrentLocation { 
self.isFirstUpdate = YES; 
[self.locationManager startUpdatingLocation]; 
} 

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { 
if (self.isFirstUpdate) { 
    self.isFirstUpdate = NO; 
    return; 
} 

CLLocation *location = [locations lastObject]; 

if (location.horizontalAccuracy > 0) { 
    self.currentLocation = location; 
    [self.locationManager stopUpdatingLocation]; 
} 
} 

- (RACSignal *)updateCurrentConditions { 
return [[self.client fetchCurrentConditionsForLocation:self.currentLocation.coordinate] 
doNext:^(WXCondition *condition) { 
    self.currentCondition = condition; 
}]; 
} 
+0

사람들이 당신을 도울 수 있기 전에 더 많은 정보를 제공해야합니다. 어디야? 도시 이름이 뭐가 잘못 되었나요? iPhone은 그것이 어디라고 생각합니까? iPhone의 위치를 ​​파악하기 위해 어떤 코드를 사용합니까? 어떤 코드를 사용하여 위치를 도시 이름으로 변환합니까? 지금 당신의 질문은 "나는 무언가를했고 작동하지 않습니다"라는 유일한 대답은 "당신이 잘못했기 때문"입니다. – Craig

+0

괜찮아요, 편집 및 추가 된 코드. – Pierre

+0

또한 "완전히 틀린"의미를 설명해야합니다. 샌프란시스코에서 오클랜드 (부정확 한 GPS)를 사용하고 있다면 Syndey에 도착하여 Bejing (좌표가 뒤집 혔을 때)과 다른 문제 일 수 있습니다. – Craig

답변

0

그것을 해결! 멍청한 실수. viewDidLoad의 레이블 만 업데이트하여 도시 이름이 변경되지 않았지만 좌표가 정확합니다.

+0

그런 다음 답으로 표시하십시오. –

0

코드에서 정확도가 0보다 높을 때 위치 업데이트를 중지하지만 정확도가 10,000km 인 경우 어떻게됩니까? 대신 위치가 유효한지 확인한 다음 정확도가 일부 값보다 낮아야하는지 확인해야합니다. 그 속성의 이름은 그리 좋지 않습니다. 이 경우 정확도가 낮을수록 위치가 더 정확합니다.

관련 문제