在 Swift 中单击右侧菜单时打开左侧菜单

Left Side Menu opens when Right Side Menu is Clicked in Swift

我正在使用 ENSideMenu Library 在 Swift 的导航栏中创建菜单。我已经创建了导航栏的左侧菜单,但是当我创建右侧时。发生的事情是,当我单击包含显示右侧菜单的操作的右侧按钮时......显示的是左侧菜单。这是我当前的实现。

RightSideNavigationController

override func viewDidLoad() {

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let menu = storyboard.instantiateViewController(withIdentifier: "RightMenuTableViewController") as! RightMenuTableViewController

    sideMenu = ENSideMenu(sourceView: self.view, menuViewController: menu, menuPosition: ENSideMenuPosition.right)
    sideMenu?.menuWidth = 200
    view.bringSubview(toFront: navigationBar)
}

RightMenuTableViewController

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    var destView: UIViewController!
    if indexPath.row == 0 {
        destView = storyboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
    } else {
          destView = storyboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController

   }
   sideMenuController()?.setContentViewController(destView)

}

SideNavigationController

override func viewDidLoad() {

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let menu = storyboard.instantiateViewController(withIdentifier: "MenuTableViewController") as! MenuTableViewController
    sideMenu = ENSideMenu(sourceView: self.view, menuViewController: menu, menuPosition: ENSideMenuPosition.left)
    sideMenu?.menuWidth = 200
    view.bringSubview(toFront: navigationBar)
}

MenuTableViewController

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    var destinationViewController: UIViewController!



    if indexPath.section == 0{
        if indexPath.row == 0 {
            destinationViewController = storyboard.instantiateViewController(withIdentifier: "TopViewController") as! TopViewController
        } else if indexPath.row == 1 {
              destinationViewController = storyboard.instantiateViewController(withIdentifier: "MemberListViewController") as! MemberListViewController
        }
     }else {
         if indexPath.row == 0 {
             destinationViewController = storyboard.instantiateViewController(withIdentifier: "MemberRegisterViewController") as! MemberRegisterViewController

        } else if indexPath.row == 3 {
              destinationViewController = storyboard.instantiateViewController(withIdentifier: "UserRegistrationViewController") as! UserRegistrationViewController
        }

    }
    sideMenuController()?.setContentViewController(destinationViewController)

}

ENSideMenu 库目前不支持在同一页面中使用该库的 2 个菜单。这是根据 ENSideMenu Library GitHub

中发布的问题