0

テーブルビューの任意のセルに触れたときに、マップ ビューに注釈を追加する必要があります。注釈 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];

 }
4

1 に答える 1