when I try to navigate new view controller the code run but don't do the job
the code for cell :
protocol NavigateViewControllerDelegate {
func navigate(destination : String)
}
class LoginCell : UICollectionViewCell {
var delegate : NavigateViewControllerDelegate?
override init(frame: CGRect) {
super.init(frame: frame)
setupViews()
}
func setupViews () {
...
loginButton.addTarget(self, action: #selector(login), for: .touchUpInside)
...
}
@objc func login(){
...
self.delegate = ViewController() as NavigateViewControllerDelegate
self.delegate.navigate(destination: "MainMenu")
...
}
}
and in the view controller :
class ViewController : UICollectionViewController,NavigateViewControllerDelegate {
...
func navigate(destination: String){
print("navigate to main menu")
self.navigationController?.pushViewController(MainMenuVC(), animated: true)
}
}
the code run and the print instruction done and print "navigate to main menu" in consul but the app didn't navigate Main menu view controller