2012-01-20 6 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]; 
} 

である私はより多くのボタンはあなたが私が したい場合は、ピンあたりのピンが別のビューにすでにある押されたクリックこれをどうやって行うのか分からない。 どのような現在のステータスでも、同じ詳細ページが付属しているピンを選択してください たとえば、 ボタンが押されているのがビッグベンです。ウェブビュー ウェストミンスター橋はテキストビューになるように押されています したいと思います。 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"送信者:送信者]; ([[mapView.selectedAnnotations objectAtIndex:1] title]); } } これは機能しません。私はあなたの助けが必要です;;;注釈をクリックした場合、別の注釈ボタン - >次の同じページ。 – unripeapple

関連する問題