Detailed view of the pin callout view would like to give a different value

575 views Asked by At

Here is my Code

@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];
}

I click the More button is pressed pins per pin is already in a different view if you wish to I do not even know how to do this one. Whatever the current status, select any pin comes with the same details page For example, it is Big Ben coming out of the button is pressed, webview Westminster Bridge is pressed to come to textview I want to make. Note that I can use xcode 4.2 version and storyboard. Here are a few days to spend in it for me I will thank you.

1

There are 1 answers

1
Patrik Svensson On
// 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]);
    }
}