我在地图上有一个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];
}

最佳答案

您需要使用NibName或情节提要中的标识符初始化MnhmeioViewController。还可以将MnhmeioViewController设置为类级别的属性,这是添加视图控制器时的更好方法。

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

关于ios - CalloutAccessoryControlTapped后空白的ViewController,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20283348/

10-10 15:59