第二个视图中的侧边菜单不起作用
Side menu in a second View doesn't work
StoryBoard click here
这是我的故事板的印刷品
我正在使用 SWRevealViewController 构建侧边菜单,但它在登录场景后的主视图中不起作用,我将 SWRevealViewController 视图与登录和菜单连接,我还尝试创建一个与主视图继续,但没有任何反应。
我实现了代码
if self.revealViewController() != nil {
menuBtn.target = self.revealViewController()
menuBtn.action = #selector(SWRevealViewController.revealToggle(_:))
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
在主视图控制器中,按钮不起作用。
找到解决方案,我不得不以这种方式登录主视图:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let sw = storyboard.instantiateViewControllerWithIdentifier("SWRevealViewController") as! SWRevealViewController
self.view.window?.rootViewController = sw
let destinationController = self.storyboard?.instantiateViewControllerWithIdentifier("StoryboardID") as! NameOfViewController
let navigationController = UINavigationController(rootViewController: destinationController)
sw.pushFrontViewController(navigationController, animated: true)
StoryBoard click here 这是我的故事板的印刷品
我正在使用 SWRevealViewController 构建侧边菜单,但它在登录场景后的主视图中不起作用,我将 SWRevealViewController 视图与登录和菜单连接,我还尝试创建一个与主视图继续,但没有任何反应。
我实现了代码
if self.revealViewController() != nil {
menuBtn.target = self.revealViewController()
menuBtn.action = #selector(SWRevealViewController.revealToggle(_:))
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
在主视图控制器中,按钮不起作用。
找到解决方案,我不得不以这种方式登录主视图:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let sw = storyboard.instantiateViewControllerWithIdentifier("SWRevealViewController") as! SWRevealViewController
self.view.window?.rootViewController = sw
let destinationController = self.storyboard?.instantiateViewControllerWithIdentifier("StoryboardID") as! NameOfViewController
let navigationController = UINavigationController(rootViewController: destinationController)
sw.pushFrontViewController(navigationController, animated: true)