gpt4 book ai didi

ios - map 未显示注释

转载 作者:行者123 更新时间:2023-11-28 22:13:04 26 4
gpt4 key购买 nike

我在 mapView 中添加了注释,但未显示。

map 出现,并以预期位置为中心。 map 中心坐标与注释坐标相同。

欢迎任何检测问题所在的帮助。

#import "mapKitViewController.h"
#import "Annotation.h"

@interface mapKitViewController ()

@end

//AYUNTAMIENTO DE LAS PALMAS DE GC
#define LP_LATITUDE 28.1249625;
#define LP_LONGITUDE -15.4286931;
//span
#define THE_SPAN 0.01f;



@implementation mapKitViewController
@synthesize myMapView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Localízame";


//DATOS DEL MAPA
//region
MKCoordinateRegion myRegion;

//centro del mapa
CLLocationCoordinate2D center;
center.latitude = LP_LATITUDE;
center.longitude = LP_LONGITUDE;

//span
MKCoordinateSpan span;
span.latitudeDelta = THE_SPAN;
span.longitudeDelta = THE_SPAN;

myRegion.center = center;
myRegion.span = span;

[myMapView setRegion:myRegion animated:YES];

//annotation
CLLocationCoordinate2D ayuntamiento;
ayuntamiento.latitude = LP_LATITUDE;
ayuntamiento.longitude = LP_LONGITUDE;

Annotation *aytoPin;
aytoPin.coordinate = ayuntamiento;
aytoPin.title = @"Ayuntamiento";
aytoPin.subtitle = @"Las Palmas de Gran Canaria";
[myMapView addAnnotation:aytoPin];
}

最佳答案

我不知道 Annotation 是什么(而不是内置的 MKPointAnnotation 或类似的),但我假设它知道如何正确绘制自己。

那么,问题是:

Annotation *aytoPin;
aytoPin.coordinate = ayuntamiento;

您没有创建注释(allocinit)。所以 aytoPin 为 nil,什么也没有发生。这里没有对象。

(这种错误很容易被抓到,因为你后续的消息都是指向 nil 的消息,这在 Objective-C 中不是错误。所以不会发生任何事情来提醒你这个问题。)

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

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