【问题标题】:Side menu in a second View doesn't work第二个视图中的侧边菜单不起作用
【发布时间】:2017-05-12 00:55:45
【问题描述】:

StoryBoard click here 这是我的故事板的印刷品

我正在使用 SWRevealViewController 构建一个侧面菜单,但它在登录场景之后的主视图中不起作用,我将 SWRevealViewController 视图与登录名和菜单连接起来,我还尝试使用主视图,但没有任何反应。

我实现了代码

        if self.revealViewController() != nil {
        menuBtn.target = self.revealViewController()
        menuBtn.action = #selector(SWRevealViewController.revealToggle(_:))
        self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
    }

在主视图控制器中,按钮不起作用。

【问题讨论】:

    标签: ios swift xcode storyboard swrevealviewcontroller


    【解决方案1】:

    找到了解决方案,我不得不以这种方式登录主视图:

    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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-28
      • 2017-10-04
      • 1970-01-01
      • 2020-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-26
      相关资源
      最近更新 更多