iOS-Slide-Menu中的不同视图控制器



我使用的是aryext/iOS-Slide-Menu。我的问题是:我需要显示不同的左菜单取决于哪个视图控制器被显示。这是我在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;

我试了很多方法,但都不起作用。谢谢!

我只知道一个解:

 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(当更改语言而不重启应用程序时使用)

我建议自定义leftMenuViewController,设置一个全局变量并根据全局变量的值在左菜单中显示不同的tableview内容,或者在leftMenuViewController中处理SlideNavigationControllerDidReveal通知,并根据当前打开的侧视图控制器添加任何子视图或删除子视图

相关内容

  • 没有找到相关文章

最新更新