보기를로드 할 때 사용자의 현재 위치에 주석을 추가하려고합니다. 어떻게해야합니까? 내가 새 것처럼 예제가 있다면 좋을 것입니다.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];
주석 헤더 클래스 다음과 같습니다
나는 이것을 알고 있지만 그것이 내가 원하는 것은 아니다. 내 자신의 주석을 추가하고 싶습니다. – deathman91
viewDidAppear에서 사용자의 현재 위도 및 경도를 가져 오려면 어떻게해야합니까? – deathman91
'CLLocationManager'의'coordinate' 속성으로 현재 좌표를 얻을 수 있습니다 - http://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLLocation_Class/CLLocation/CLLocation.html# // apple_ref/doc/uid/TP40007126 –