gpt4 book ai didi

ios - MapKit 引脚上的注释未显示

转载 作者:行者123 更新时间:2023-11-29 13:39:16 25 4
gpt4 key购买 nike

我在 map 上放置了两个图钉,单击时每个图钉都有一个注释,但是,只显示了 StoreLocationOne 的注释。 map 上的两个图钉都已显示,但单击时未显示 StoreLocationTwo 注释,有什么想法吗?

-(void)viewDidLoad {
[super viewDidLoad];

[mapview setMapType:MKMapTypeStandard];
[mapview setZoomEnabled:YES];
[mapview setScrollEnabled:YES];

MKCoordinateRegion region = { {0.0, 0.0 }, {0.0, 0.0 } };
region.center.latitude = 57.132053;
region.center.longitude = -2.135592;
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapview setRegion:region animated:YES];

StoreLocationOne *ann = [[StoreLocationOne alloc] init];
ann.title = @"Heavenly Pizzas Mannofield";
ann.subtitle = @"483a Great Western Rd, Aberdeen, AB10 6NN";
ann.coordinate = region.center;
[mapview addAnnotation:ann];

MKCoordinateRegion region2 = { {0.0, 0.0 }, {0.0, 0.0 } };
region2.center.latitude = 57.232458;
region2.center.longitude = -2.347853;
region2.span.longitudeDelta = 0.01f;
region2.span.latitudeDelta = 0.01f;

StoreLocationTwo *ann2 = [[StoreLocationTwo alloc] init];
ann2.title2 = @"Heavenly Pizzas Kintore";
ann2.subtitle2 = @"School Road, Kintore, AB51 0UU";
ann2.coordinate = region2.center;
[mapview addAnnotation:ann2];

}

最佳答案

titlesubtitle 属性必须准确命名。 map View 不知道要查找 title2subtitle2

您可以有多个实现 MKAnnotation 的类,但属性名称必须符合协议(protocol)。

此外,如果您只需要属性 coordinatetitlesubtitle,您可以使用内置注释类 MKPointAnnotation 而不是为每个坐标创建一个单独的类。

关于ios - MapKit 引脚上的注释未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9619548/

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