1

我正在使用aryaxt/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;

我尝试了很多东西,但没有任何效果。谢谢!

4

2 回答 2

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

于 2017-07-13T06:31:05.313 回答
0

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

于 2015-10-27T08:37:46.783 回答