calloutAccessoryControlTapped后的空白ViewController

时间:2013-11-29 10:16:04

标签: ios mkmapview mapkit mapkitannotation

我在地图上有一个MKMapView和一些标记。当用户点击标记时,MKAnnotationView会出现titlebutton类型UIButtonTypeDetailDisclosure

当用户点击按钮时,它应该转到另一个viewController。问题是,当新的viewController出现时,它是空白的,并且它没有我在故事板中给出的格式。

以下是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];
}

1 个答案:

答案 0 :(得分:1)

您需要使用Storyboard中的NibName或标识符初始化MnhmeioViewController。另外,在类级别上将MnhmeioViewController作为属性,添加视图控制器时更好。

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"YourStoryBoard" bundle:nil];
MnhmeioViewController * destViewController = [storyboard instantiateViewControllerWithIdentifier:@"MnhmeioViewController"];