0

I have a MKMapView and some markers on the map. When user taps a marker an MKAnnotationView comes up with a title and a button of type UIButtonTypeDetailDisclosure.

When the user taps the button it should go to another viewController. The problem is that when the new viewController comes up , it is blank and it doesn't have the format that I have gave it in the storyboard.

Here is the code for calloutAccessoryControlTapped:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {

    MnhmeioViewController * destViewController = [[MnhmeioViewController alloc] init];

    Annotation *which=view.annotation;
    NSString *whichString=which.title;

    Group *tmpGroup;

    for(int i=0; i<allGroups.count; i++) {

        Group *checkGroup=[allGroups objectAtIndex:i];

        if ([checkGroup.title isEqualToString:whichString]) {
            tmpGroup=checkGroup;
            break;
        }
    }

    NSString *mnhmeioName=tmpGroup.title;
    destViewController.titleNavBar = mnhmeioName;
    destViewController.selectedArthro = tmpGroup;

    [self.navigationController pushViewController:destViewController animated:YES];
}
Wain
  • 118,658
  • 15
  • 128
  • 151
hoya21
  • 893
  • 7
  • 24

1 Answers1

1

You need to initialize the MnhmeioViewController with NibName or identifier from Storyboard. Also make your MnhmeioViewController as property on class level , it is better approach when adding view controllers.

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"YourStoryBoard" bundle:nil];
MnhmeioViewController * destViewController = [storyboard instantiateViewControllerWithIdentifier:@"MnhmeioViewController"];
nsgulliver
  • 12,655
  • 23
  • 43
  • 64