2011-08-15 2 views
0

보기를로드 할 때 사용자의 현재 위치에 주석을 추가하려고합니다. 어떻게해야합니까? 내가 새 것처럼 예제가 있다면 좋을 것입니다.viewDidAppear시 사용자 위치 표시

감사합니다. '

@interface LocationAnnotation : NSObject <MKAnnotation> { 

UIImage *image; 
NSNumber *latitude; 
NSNumber *longitude; 
NSString *locationTitle; 
NSString *locationSubtitle; 
} 

@property (nonatomic, retain) UIImage *image; 
@property (nonatomic, retain) NSNumber *latitude; 
@property (nonatomic, retain) NSNumber *longitude; 

@property(nonatomic,retain) NSString *locationTitle; 
@property(nonatomic,retain) NSString *locationSubtitle; 

-(id)initWithLatitude:(NSNumber *)aLatitude andLongitude:(NSNumber *)aLongitude andTitle:(NSString *)aLocationTitle andSubtitle:(NSString *)aLocationSubtitle; 

@end 

addAnnotation 방법 MKAnnotation 의정서는 무엇인가 :

// Set up the annotation 
LocationAnnotation *annotation = [[LocationAnnotation alloc] initWithLatitude:[numberFormatter numberFromString:[[location valueForKey:@"latitude"] description]] andLongitude:[numberFormatter numberFromString:[[location valueForKey:@"longitude"] description]] andTitle:[location valueForKey:@"name"] andSubtitle:[location valueForKey:@"notes"]]; 
[numberFormatter release]; 

[self.mapView addAnnotation:annotation]; 

주석 헤더 클래스 다음과 같습니다

답변

1

은 주석으로 현재 위치를 표시로서 나는 다음과 같은 짓을 다시 이것을 찾으려고.

사용자 정의 위치를 ​​표시 할 경우

, 당신은 창조의 주위에 나오지 않습니다 여기에 언급 자신의 MKAnnotation 같이

loading custom image on mkmaps

+0

나는 이것을 알고 있지만 그것이 내가 원하는 것은 아니다. 내 자신의 주석을 추가하고 싶습니다. – deathman91

+0

viewDidAppear에서 사용자의 현재 위도 및 경도를 가져 오려면 어떻게해야합니까? – deathman91

+0

'CLLocationManager'의'coordinate' 속성으로 현재 좌표를 얻을 수 있습니다 - http://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLLocation_Class/CLLocation/CLLocation.html# // apple_ref/doc/uid/TP40007126 –

1

당신이 당신의 MKMapViewYES에의 showsUserLocation 속성을 설정해야합니다.

이 속성 만 을 사용하면 사용자 위치가으로 표시됩니다.