2013-04-26 3 views
1

여러 주석 주석 공개 버튼이 다른보기를 열 수있게하는 방법을 찾고 있습니다. 예를 들어, annotation1 공개 버튼은 ViewController 1.xib를 열어야하고, annotation2는 ViewController2.xib를 열어야합니다. 이것이 가능한가?MKMapView에서 다른 주석에 대해 다른 동작 설정

좌표를 기준으로 위치를 설정하고 사용자 위치를 설정하는이 코드가 있습니다.

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control 
{ 
// ??? 
} 

모든 도움에 감사드립니다 : 여기에 투입 할 무엇

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
_mapView.showsUserLocation = YES; 
CLLocationCoordinate2D annotationCoord; 

annotationCoord.latitude = 40.714353; 
annotationCoord.longitude = -74.005973; 
coord = 1; 
MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init]; 
annotationPoint.coordinate = annotationCoord; 
annotationPoint.title = @"New York"; 
[_mapView addAnnotation:annotationPoint]; 

CLLocationCoordinate2D annotationCoord1; 

annotationCoord1.latitude = 51.511214; 
annotationCoord1.longitude = -0.119824; 
coord = 2; 
MKPointAnnotation *annotationPoint1 = [[MKPointAnnotation alloc] init]; 
annotationPoint1.coordinate = annotationCoord1; 
annotationPoint1.title = @"London"; 
[_mapView addAnnotation:annotationPoint1]; 
} 

- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
MKPinAnnotationView *mapPin = nil; 
if(annotation != map.userLocation) 
{ 
    static NSString *defaultPinID = @"defaultPin"; 
    mapPin = (MKPinAnnotationView *)[map dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; 
    if (mapPin == nil) 
    { 
     mapPin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation 
                reuseIdentifier:defaultPinID] autorelease]; 
     mapPin.canShowCallout = YES; 
     UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
     mapPin.rightCalloutAccessoryView = infoButton; 
    } 
    else 
     mapPin.annotation = annotation; 

} 
return mapPin; 
} 

. 감사합니다

답변

1

당신이 뭔가를 할 수

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control 
{ 
    if ([view.annotation.title isEqualToString:@"The titel of your annotation"]) 
    { 
    // Do something 
    } 
} 
관련 문제