2012-01-20 36 views
0

這裏是我的代碼銷標註視圖的詳細視圖想給不同的值

@implementation AnnotationViewController 
@synthesize mapView; 

-(void)viewDidLoad { 

    [super viewDidLoad]; 
    [mapView setMapType:MKMapTypeStandard]; 
    [mapView setZoomEnabled:YES]; 
    [mapView setScrollEnabled:YES]; 
    [mapView setDelegate:self]; 

    MKCoordinateRegion bigBen = { {0.0, 0.0} , {0.0, 0.0} }; 
    bigBen.center.latitude = 51.50063; 
    bigBen.center.longitude = -0.124629; 
    bigBen.span.longitudeDelta = 0.02f; 
    bigBen.span.latitudeDelta = 0.02f; 
    [mapView setRegion:bigBen animated:YES]; 

    Annotation *ann1 = [[Annotation alloc] init]; 
    ann1.title = @"Big Ben"; 
    ann1.subtitle = @"Your subtitle"; 
    ann1.coordinate = bigBen.center; 
    [mapView addAnnotation: ann1]; 

    MKCoordinateRegion Bridge = { {0.0, 0.0} , {0.0, 0.0} }; 
    Bridge.center.latitude = 51.500809; 
    Bridge.center.longitude = -0.120914; 
    Bridge.span.longitudeDelta = 0.02f; 
    Bridge.span.latitudeDelta = 0.02f; 
    [mapView setRegion:Bridge animated:YES]; 

    Annotation *ann2 = [[Annotation alloc] init]; 
    ann2.title = @"Westminster Bridge"; 
    ann2.subtitle = @"Your subtitle"; 
    ann2.coordinate = Bridge.center; 
    [mapView addAnnotation:ann2]; 

} 

-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { 


    MKPinAnnotationView *MyPin=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"current"]; 
    MyPin.pinColor = MKPinAnnotationColorGreen; 

    UIButton *advertButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    [advertButton addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside]; 

    MyPin.rightCalloutAccessoryView = advertButton; 
    MyPin.draggable = NO; 
    MyPin.highlighted = YES; 
    MyPin.animatesDrop=TRUE; 
    MyPin.canShowCallout = YES; 


    return MyPin; 
} 
-(void)button:(id)sender { 

    NSLog(@"Button action"); 
    [self performSegueWithIdentifier:@"detail" sender:sender]; 
    [self performSegueWithIdentifier:@"under" sender:sender]; 
} 

我點擊更多的按鈕被按下每個PIN腳已經處於不同的看法,如果你想 我甚至不知道如何做到這一點。 無論目前的狀態,選擇任意引腳自帶 相同的細節頁。例如, 這是大本鐘出來的按鈕被按下,網頁流量 威斯敏斯特橋壓來的TextView 我要打。 請注意,我可以使用xcode 4.2版本和故事板。 以下是幾天內對我的支持,我會感謝你。

回答

0
// You can probably use the property selectedAnnotations in MKMapView 
// You might want to consider adding some more error checking 

-(void)button:(id)sender { 
    if ([mapView.selectedAnnotations count] >= 1) { 
     NSLog(@"%@title = %@", [[mapView.selectedAnnotations objectAtIndex:0] title]); 
    } 
} 
+0

- (無效)按鈕:(ID)發送方{ 如果([mapView.selectedAnnotations計數]> = 1){ [自performSegueWithIdentifier:@ 「細節」 發件人:發送者]; ([[mapView.selectedAnnotations objectAtIndex:0] title]); // NSLog([[mapView.selectedAnnotations objectAtIndex:0] title]); } else if([mapView.selectedAnnotations count]> = 2){self performSegueWithIdentifier:@「under」sender:sender]; ([[mapView.selectedAnnotations objectAtIndex:1] title]); } } 它不工作我需要你的幫助;;;如果我點擊註釋調出按鈕另一個註釋 - >相同的下一頁; – unripeapple