의 하위 제목을 표시하지 않습니다. 두 개의 변수 (제목 및 부제목)를 예약했습니다.이 예에서는 단어 USA
(제목) 만 표시됩니다. PIN을 클릭하면내 주석은 PIN을 표시하는 구현 클래스에서 PIN
CLLocationCoordinate2D location2D = (CLLocationCoordinate2D){ .latitude = latitudeOfUserLocation, .longitude = longitudeOfUserLocation };
ManageAnnotations *annotation=[[ManageAnnotations alloc]initWithTitle:@"USA" adresseDuTheme:@"Colorado" coordinate:location2D];//only USA is displayed
annotation.pinColor = MKPinAnnotationColorRed; //or red or whatever
[self->mapView addAnnotation:annotation];
MKCoordinateSpan span={.latitudeDelta=1,.longitudeDelta=0.5};
MKCoordinateRegion region={location2D,span};
[mapView setRegion:region];
ManageAnnotations 클래스에서 제목과 부제에 대해 두 가지 변수를 예약했습니다. 지도보기는 호출하지 것이다
@property (nonatomic, readonly, copy) NSString *subtitle
주 subtitle
모든 소문자하지만 클래스는 subTitle
(대문자 T
)가 :
@interface ManageAnnotations : NSObject<MKAnnotation>{
NSString *_libelle;
NSString *_adresse;
CLLocationCoordinate2D _coordinate;
}
//
@property(nonatomic,assign)MKPinAnnotationColor pinColor;
@property(copy)NSString *libelle;
@property(copy)NSString *adresse;
@property(nonatomic,readonly)CLLocationCoordinate2D coordinate;
-(id)initWithTitle:(NSString*)libelle adresseDuTheme:(NSString*)adresse coordinate:(CLLocationCoordinate2D)coordinate;
@end
#import "ManageAnnotations.h"
@implementation ManageAnnotations
@synthesize pinColor;
@synthesize libelle=_libelle;
@synthesize adresse=_adresse;
@synthesize coordinate=_coordinate;
-(id)initWithTitle:(NSString*)libelle adresseDuTheme:(NSString*)adresse coordinate:(CLLocationCoordinate2D)coordinate{
if((self=[super init])){
_libelle=[libelle copy];
_adresse=[adresse copy];
_coordinate=coordinate;
}
return self;
}
-(NSString*)title{
return _libelle;
}
-(NSString*)subTitle{
return _adresse;
}
@end
백만 thanx :) – Malloc