2012-08-24 2 views

답변

2

여기 CLLocationManager 등급은 위도, 경도, 정확도 및 속도와 같은 다른 위치를 제공합니다.

난 당신이 에 현재 속도를 얻을 수 내가이 울부 짖는 소리 메소드를 호출하므로 위치 업데이트를 CoreLocationController를 사용 - (무효) locationUpdate : 울부 짖는 소리가 그렇지 우는 소리

- (void)locationUpdate:(CLLocation *)location 
{ 
    NSString *currentspeed = [NSString stringWithFormat:@"SPEED: %f", [location speed]]; 
} 

나 같은 (CLLocation *) 위치 방법 대리자 메서드

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{ 
    NSLog(@"in update to location"); 
    NSString *currentspeed = [NSString stringWithFormat:@"SPEED: %f", [newLocation speed]]; 
} 

이 링크에서 예를 얻을 수 있습니다 ... http://www.vellios.com/2010/08/16/core-location-gps-tutorial/

난이 도움이 ... :

+0

선생님, 나는 그 링크를 읽었으며 또한 시도했지만, 내 목표를 달성하지 못했습니다. (정확하지 않거나 거의 정확한 속도를 내지 못합니다) ... –

+0

ok http://mobileorchard.com/hello -here-a-corelocation-tutorial/ –

+0

이 iOS SDK 예제에서는 CoreLoactionController와 같은 방식으로이 코드를 사용합니다. 또한 이것을 사용하십시오 .... https://developer.apple.com/library/ios/#samplecode /LocateMe/Introduction/Intro.html –

0

컨트롤러 헤더 파일에 추가 대리자 CLLocationManagerDelegate가 있기를 바랍니다.

초기화 위치 관리자는 당신이

self.locationManager = [[CLLocationManager alloc] init]; 
self.locationManager.delegate = self; // send loc updates to current class 

같은 위치 관리자의 대리자 메서드를 구현하는 대리자를 설정하고이

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 
    NSLog(@"Location Speed: %f", newLocation.speed); 
} 

그거야 당신이 얻을 것이다 클래스에 메서드를 작성 할 수 있습니다 속도로 위의 방법에서 위치 업데이트 또한 가능하면 자주 실행됩니다.

+0

또 다른 좋은 예가 있습니다. http://www.iphonedevsdk.com/forum/iphone-sdk-development/18209-crazy-speed-gps-myclcontroller-corelocation.html –

+0

@Adeel .... Automotive reference 내 프로그램에서 카운팅이 가능하므로 ... "위임 속성은 unsafe_unretained 여야합니다"라는 오류 메시지가 표시됩니다. –

+0

알았어, 내 대답이 업데이트 중이며 지금은 정상적으로 작동되기를 바랍니다. –