Im trying to bring out the viewcontroller after i select an item in the menu. Currently, when I press something it just change the page, but it gets stuck on the right side. How do i bring that out.
This is the code that i wrote.
class ContainerVC: UIViewController {
var sideMenuOpen = false
@IBOutlet weak var mainView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self,
selector: #selector(toggleSideMenu),
name: NSNotification.Name("ToggleSideMenu"),
object: nil)
}
@IBOutlet weak var sideMenuConstraint: NSLayoutConstraint!
@objc func toggleSideMenu() {
if sideMenuOpen {
sideMenuOpen = false
sideMenuConstraint.constant = -270
} else {
sideMenuOpen = true
sideMenuConstraint.constant = 0
}
UIView.animate(withDuration: 0.3) {
self.view.layoutIfNeeded()
}
}
}
And this is what i wrote in my SideMenuVC
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print(indexPath.row)
// NotificationCenter.default.post(name: NSNotification.Name ("ToggleSideMenu"), object: nil)
switch indexPath.row {
case 0: NotificationCenter.default.post(name: NSNotification.Name ("ShowProfile"), object: nil)
case 8: //signs out of Firebase
try? Auth.auth().signOut()
//signs out of Facebook
FBSDKAccessToken.setCurrent(nil)
let main = UIStoryboard(name: "Main", bundle: nil)
let second = main.instantiateViewController(withIdentifier: "loginPage")
self.present(second, animated: true, completion: nil)
default: break
//https://www.youtube.com/watch?v=Hl_Re_KLhcY
}
}
And this is what i wrote in my HomeVC
@IBAction func menuButton() {
print("Toggle Side Menu")
NotificationCenter.default.post(name: NSNotification.Name("ToggleSideMenu"), object: nil)
}
i would like the selected page to come out.