我将Side Menu作为SlideMenu。但我希望它从我的ShopHome屏幕开始。在我的应用程序中,我的根/初始VC是“登录”页面。当我使用以下代码时,它将直接转到ShopHome。但是我希望我的应用程序从登录名开始,然后从ShopHome屏幕上的菜单开始。我尝试将root更改为LoginVC,但是在ShopHome页面上时菜单不起作用。

AppDelegate

    let storyboard = UIStoryboard(name: "Main", bundle: nil)

    let mainViewController = storyboard.instantiateViewController(withIdentifier: "ShopHomeVC") as! ShopHomeVC
    let rightViewController = storyboard.instantiateViewController(withIdentifier: "RightMenuVC") as! RightMenuVC
    let nvc: UINavigationController = UINavigationController(rootViewController: mainViewController)

    let slideMenuController = SlideMenuController(mainViewController: nvc, rightMenuViewController: rightViewController)
    self.window?.rootViewController = slideMenuController
    self.window?.makeKeyAndVisible()

最佳答案

我检查了幻灯片菜单

使用它并委托添加

 let leftViewController = storyboard.instantiateViewController(withIdentifier: "LeftViewController") as! LeftViewController
 let rightViewController = storyboard.instantiateViewController(withIdentifier: "RightViewController") as! RightViewController
 let nvc: UINavigationController = UINavigationController(rootViewController: mainViewController)
 let slideMenuController = SlideMenuController(mainViewController:  nvc,leftMenuViewController: leftViewController, rightMenuViewController: rightViewController)

 slideMenuController.automaticallyAdjustsScrollViewInsets = true
 slideMenuController.delegate = mainViewController
 self.window?.rootViewController = slideMenuController
 self.window?.makeKeyAndVisible()

10-08 11:00