gpt4 book ai didi

ios - 我的注释未在 PIN 码中显示副标题

转载 作者:行者123 更新时间:2023-12-01 17:27:33 24 4
gpt4 key购买 nike

在负责显示 PINS 的实现类中,我保留了两个变量(标题和副标题),在本例中,只有单词 USA (标题)在我单击 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 类中,我为标题和副标题保留了两个变量。
@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

最佳答案

MKAnnotation协议(protocol)定义了 subtitle属性为:

@property (nonatomic, readonly, copy) NSString *subtitle

备注 subtitle都是小写,但你的类(class)有 subTitle (大写 T ) map View 不会调用。

将方法声明更改为:
-(NSString*)subtitle

关于ios - 我的注释未在 PIN 码中显示副标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8743790/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com