0

MKMapView在地图上有一个和一些标记。当用户点击标记时,MKAnnotationView会出现 atitle和 abutton类型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];
}
4

1 回答 1

1

您需要使用来自 Storyboard 的 NibName 或标识符初始化 MnhmeioViewController。还将您的 MnhmeioViewController 作为类级别的属性,这是添加视图控制器时更好的方法。

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"YourStoryBoard" bundle:nil];
MnhmeioViewController * destViewController = [storyboard instantiateViewControllerWithIdentifier:@"MnhmeioViewController"];
于 2013-11-29T10:17:22.293 回答