如何在另一个视图控制器中加载MKMapView

时间:2014-03-11 19:23:56

标签: ios iphone objective-c performance mkmapview

正如标题所述,我正在尝试在单独的视图控制器中加载MKMapView,然后在完成后执行推送segue(从FirstViewControllerMapViewController)。这是我的初始化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加载到其他视图控制器?

0 个答案:

没有答案