Fabio Cardoso
Fabio Cardoso

Reputation: 1269

Go to another viewcontroller after click on a pin mapkit

I have multi pin on my map (about restaurants, hotels etc..), on that pins I have an "arrow" (rightcalloutaccessoryview). The coordinates are stored on the sqlite database.

I can get the coordinates and the right id when I click on the pin then I'm checking on the DB where are that coordinates.

Objective: When I click on the a hotel pin I want to go to that detail ViewController (that loads with the id of that hotel)

Any ideias?

Upvotes: 0

Views: 294

Answers (1)

user2223516
user2223516

Reputation:

yes try the below example code. here i used to differentiate annotation (pin) with their titles. and used map view delegate methods

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view
   calloutAccessoryControlTapped:(UIControl *)control
{
    NSLog(@"accessory button tapped for annotation %@", [view.annotation title]);

    if([[view.annotation title] isEqualToString:@"one"])
    { 
           // Push to another view controller code here
    }
}

 

Upvotes: 1

Related Questions