2013-07-15 1 views
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]; 

} 

답변

2

mapView: viewForAnnotation: 방법,이 방법은지도보기 내부적으로 호출지도보기의 delegate 방법 때 ADD 또는,지도보기에서 REMOVE 어떤 주석 .

당신이 tableView:didSelectRowAtIndexPath:

[self.map addAnnotaion:<YOUR Annotation>]; 
에서 다음을 수행해야 TableView 탭에 주석을 추가하려면
관련 문제