I have Map with multiply annotations and I want hen user taps on pin to call another view.
I'm using storyboard.
With .xib this would be like this.
...
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
...
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
}
-(void)showDetails:(UIButton*)sender {
OfferDetailViewController *detail = [[OfferDetailViewController alloc] init];
detail.context = context;
Offers *offer = [arr objectAtIndex:indexPath.row];
//detail.offer = offer;
[self.navigationController pushViewController:detail animated:YES];
}
...
You can create a Segue between the views and give it an identifier in StoryBoard. Then execute "performSegueWithIdentifier" to trigger it. So in your method which is called by the user tapping you call the "performSegueWithIdentifier" something like this if your Segue has an identifier of "FrameSegue"
[self performSegueWithIdentifier:@"FrameSegue" sender:sender];
You can setup the transition in "prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender" if you need do any setup first to pass data to the other view.
I hope that helps.
Answer to your comment below :-
If you have a Segue Identified as "FrameSegue" and you want to pass a string from the view "MyFirstView" to the second view called "MySecondView" and store it in myData in the second view.
Try this:
In MyFirstView.m
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"FrameSegue"]) {
MySecondView *secondView = [segue destinationViewController];
[secondView setMyData:myString];
}
}
- (IBAction)tappedThing:(id)sender {
NSString *myString = @"A String";
[self performSegueWithIdentifier:@"FrameSegue" sender:sender];
}
Implement the mapView:annotationView:calloutAccessoryControlTapped:
method and put your showDetail:
implementation in there instead, possibly doing some conditional tests for the annotation view in question.