我正在开发一个基于地图的应用程序,在该应用程序中我使用侧边菜单来控制地图(即更改地图类型等)。我正在使用这个库来实现幻灯片菜单:https ://github.com/mikefrederick/MFSideMenu 。我想知道从另一个视图控制器控制一个视图控制器中的地图的最佳方法是什么?
应用代表:
- (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