正如标题所述,我正在尝试在单独的视图控制器中加载MKMapView
,然后在完成后执行推送segue(从FirstViewController
到MapViewController
)。这是我的初始化MapViewController
:
//initiate the map view controller
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:[NSBundle mainBundle]];
MapViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"MapViewController"];
viewController.mapDelegate = self;
//force -viewDidLoad to be called
[viewController view];
这很好用,并调用-viewDidLoad
。从中我设置了我的MKMapView
并将其委托设置为自己。从FirstViewController
调用委托方法时,MapViewController
会触发第二个视图控制器的segue:
//push to the map view controller
if(self.navigationController){
[self.navigationController pushViewController:mapController animated:YES];
}
问题在于,当我等到MKMapView
委托方法-mapViewWillStartLoadingMap
来调用回调时,推送segue永远不会启动。我试图通过MKMapView
强制[mapview setNeedsDisplay]
加载,但这不会产生任何结果。
如何强制MKMapView加载到其他视图控制器?