gpt4 book ai didi

objective-c - MKCircle 叠加层未绘制在 MapView 上

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

我正确地将 MapView 连接到我的委托(delegate)。此外,用户位置确实显示在 map 上,但应该显示在同一位置的 MKCircle 却没有显示。它在某个时刻起作用,但不知何故停止工作。这是我的一些代码。

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
userLocation = newLocation;
MKCircle *circle = [MKCircle circleWithCenterCoordinate:userLocation.coordinate radius:500];
circle.title = @"Nearby sites";
[worldView addOverlay:circle];
}

最佳答案

使用注释,不需要实现 viewForAnnotation 委托(delegate)方法, map View 将绘制默认的红色图钉。

但对于叠加层,您必须实现 viewForOverlay 委托(delegate)方法。
map View 不提供默认的叠加 View 。

关于objective-c - MKCircle 叠加层未绘制在 MapView 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11716465/

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