当触摸表格视图的任何单元格时,我需要向地图视图添加注释。我有一个方法,我在其中添加注释 viewForAnnotation 和方法 didSelectRowAtIndexPath。
我无法建立在哪里调用该方法以及如何调用的逻辑连接?
请你帮助我好吗?
viewForAnnotation 方法
- (MKAnnotationView *)mapView:(MKMapView *)mapView2 viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
{
return nil;
}
else if ([annotation isKindOfClass:[CustomAnnotation class]])
{
static NSString * const identifier = @"MyCustomAnnotation";
MKAnnotationView* annotationView = [mapView2 dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView)
{
annotationView.annotation = annotation;
}
else
{
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:identifier];
}
UIImageView * ecz = [[UIImageView alloc]init];
ecz.frame = CGRectMake(0, 0, 65, 49);
ecz.image = [UIImage imageNamed:@"indicator.png"];
UIImageView * vstd = [[UIImageView alloc]init];
vstd.frame = CGRectMake(33, 10, 24, 22);
vstd.image = [UIImage imageNamed:@"indicator_ziyaret_gri"];
UIImageView * nbox = [[UIImageView alloc]init];
nbox.frame = CGRectMake(48, -6, 22, 22);
nbox.image = [UIImage imageNamed:@"numara_kutusu"];
[annotationView addSubview:ecz];
[annotationView addSubview:vstd];
UILabel *index = [[UILabel alloc] initWithFrame:CGRectMake(5,4,15,15)];
index.text = @"1";
index.textColor = [UIColor whiteColor];
[index setFont:[UIFont fontWithName:@"Arial-BoldMT" size:18]];
[nbox addSubview:index];
[index setBackgroundColor:[UIColor clearColor]];
[annotationView addSubview:nbox];
annotationView.canShowCallout = YES;
return annotationView;
}
return nil;
}
didSelectRowAtIndexPath 方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
EczaneCell *cell = [tableView cellForRowAtIndexPath:indexPath];
}