我正在开发一个基于地图的应用程序,我正在使用侧边菜单来控制地图(即更改地图类型等)。我正在使用此库来实现幻灯片菜单:https://github.com/mikefrederick/MFSideMenu。我想知道从一个不同的视图控制器在一个视图控制器中控制地图的最佳方法是什么?
App代表:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];
MFSideMenuContainerViewController *container = (MFSideMenuContainerViewController *)self.window.rootViewController;
UINavigationController *navigationController = [storyboard instantiateViewControllerWithIdentifier:@"navigationController"];
UIViewController *leftSideMenuViewController = [storyboard instantiateViewControllerWithIdentifier:@"leftSideMenuViewController"];
[container setLeftMenuViewController:leftSideMenuViewController];
[container setCenterViewController:navigationController];
return YES;
}
然后我将此Action链接到主视图控制器上的一个按钮,该按钮显示侧栏如下:
- (IBAction)leftReveal:(id)sender {
[self.menuContainerViewController toggleLeftSideMenuCompletion:nil];
}
这是一段视频,展示了我试图模仿的边栏功能:http://www.youtube.com/watch?v=kbfu13fkWZ4