我正在使用aryaxt/iOS-Slide-Menu。我的问题是:我需要显示不同的左菜单,具体取决于显示哪个View Controller。这是我在AppDelegate中的代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
UserMenuViewController *leftMenu = (UserMenuViewController *) [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"UserMenuViewController"];
[SlideNavigationController sharedInstance].leftMenu = leftMenu;
当我尝试在我的特殊ViewController中更改左侧菜单时,左侧菜单中出现黑屏。
AppDelegate *sharedeDelegate = ((AppDelegate *)[UIApplication sharedApplication].delegate);
ProfessionalMenuViewController *leftMenu = (ProfessionalMenuViewController *) [sharedeDelegate.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"ProfessionalMenuViewController"];
[SlideNavigationController sharedInstance].leftMenu = leftMenu;
我尝试了很多东西,但没有任何效果。谢谢!
答案 0 :(得分:3)
我只知道一个解决方案:
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
SlideNavigationController* landingScreen = (SlideNavigationController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"SlideNavigationController"];
LeftMenuViewController *leftMenu = (LeftMenuViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"CVLeftMenuViewController"];
landingScreen.leftMenu = leftMenu;
landingScreen.enableShadow=YES;
landingScreen.enableSwipeGesture = YES;
landingScreen.panGestureSideOffset = 0;
delegate.window.rootViewController = landingScreen;
需要更新SlideNavigationController请参阅landingScreen(我在更改语言时使用,无需重新启动应用程序)
答案 1 :(得分:0)
我建议自定义leftMenuViewController,设置一个全局变量,并根据全局变量的值在左侧菜单中显示不同的tableview内容,或者在leftMenuViewController中处理SlideNavigationControllerDidReveal通知,并根据当前打开的侧视图控制器添加任何子视图或删除子视图。