Search code examples
iosobjective-cios6uistoryboardseguepushviewcontroller

pushViewController do a black view


I have a map that shows a lot annotations, and when I tap on UIButtonTypeDetailDisclosure in the callout annotationView.rightCalloutAccessoryView I will get an empty black view.

-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
    NSLog(@"%@", view.annotation.title);
    MapPoint *annView = view.annotation;
    DetailViewController *dvc = [[DetailViewController alloc] init];
    dvc.titleLabel.text = annView.title;
    dvc.textView.text = annView.subtitle;
    [self.navigationController pushViewController:dvc animated:YES];
}

Any ideas what I do wrong?

Edit: I am using Storyboard


Solution

  • If you are using Xib Interface then you should assign the NibName before pushing it on the stack.

    Using IB

    DetailViewController *dvc = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
    

    Using StoryBoard

    Make sure you have defined the Identifier as "DetailViewController" for your viewController in attributes Inspector.

    DetailViewController *dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];