我尝试在MapView中删除一个引脚注释。但事实并非如此。
视图控制器有一个表视图,我将mapView插入标题。
DetailViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Nearby";
//coord is CLLocationCoordinate2D which is instance variable
ItemMapPoint *itemMapPoint = [[SquakItemMapPoint alloc] initWithCoordinate:coord title:@"Test"];
[mapView addAnnotation:itemMapPoint];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coord, 500, 500);
[mapView setRegion:region animated:YES];
//the delegate is not set here but I set it in Interface Builder
self.tableView.tableHeaderView = mapView;
}
/this is delegate method to set Pin to drop
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKPinAnnotationView *annoView = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation
reuseIdentifier:@"current"];
annoView.animatesDrop = YES;
annoView.pinColor = MKPinAnnotationColorGreen;
return annoView;
}
当我在委托中设置时,引脚为绿色但在屏幕加载时引脚不会掉落。我试图将代码更改为ViewDidAppear(),但它仍然无效。
请帮忙。
先谢谢
答案 0 :(得分:0)
两件事 -
确保您的ItemMapPoint
和SquakItemMapPoint
实施所需的协议。
尝试在添加注释mapView
之前添加self.tableView.tableHeaderView = mapView;
即[mapView addAnnotation:itemMapPoint];
。