我在地图上有一个MKMapView
和一些标记。当用户点击标记时,MKAnnotationView
会出现title
和button
类型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];
}
答案 0 :(得分:1)
您需要使用Storyboard中的NibName或标识符初始化MnhmeioViewController。另外,在类级别上将MnhmeioViewController作为属性,添加视图控制器时更好。
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"YourStoryBoard" bundle:nil];
MnhmeioViewController * destViewController = [storyboard instantiateViewControllerWithIdentifier:@"MnhmeioViewController"];