I have looked at similar posts here about gesture recognizers not working and I have tried all of their solutions to no avail. I have created dozens of gesture recognizers in the past and its been a few hours that I can't get this one to work and I'm ready to drown myself.
Here are my 3 Horizontal stacks I have in a view: https://i.stack.imgur.com/Sj9mi.jpg
I have added a gesture recognizer to a horizontal stack like so:
menuView.addSubview(Hstack1)
Hstack1.anchor(top: nil, left: menuView.leftAnchor, bottom: nil, right: menuView.rightAnchor, paddingTop: 0, paddingLeft: 15, paddingBottom: 0, paddingRight: 15, width: menuView.frame.width, height: 30)
Hstack1.topAnchor.constraint(equalTo: menuView.topAnchor, constant: 100).isActive = true
var tap = UITapGestureRecognizer(target: self, action: #selector(openProfileController))
Hstack1.addGestureRecognizer(tap)
My function that should be triggered:
@objc func openProfileController() {
navigationController?.pushViewController(ProfileController(), animated: true)
}
I even tried making "Profile" a button with an action method but that didn't work. I also tried adding a gesture to the whole black menu view but nothing was triggered.
Edit: I have been playing around with the view for hours and I have learned that it has something to do with the menu views frame. In order to get the slide menu, I shift my view controller in an animation like this:
self.view.frame.origin.x = self.view.frame.origin.x + 250
The menu's frame is initially:
menuView.frame = CGRect(x: -250,y: 0, width: 250, height: view.frame.height)
But since it is a subview of the view controller, it shifts also 250 to the right. Visually, this is exactly what I want. However, it seems that the menuView's frame is not updated during this animation and continues to be at -250, 0.
Any ideas on how to fix this?