I'm trying to push a ViewController programmatically.
Code:
var plus = UIButton()
plus.addTarget(self, action: #selector(plusPressed), for: .touchUpInside)
@objc func plusPressed() {
print("plus")
let createJournalVC = CreateJournalViewController()
self.navigationController?.pushViewController(createJournalVC, animated: true)
}
What works:
- Once the button is pressed, "plus" is printed to the console.
What doesn't work:
- The ViewController is not pushed.
Details
- I am using a Navigation Controller & Tab Bar Controller.
- I am making this only programmatic, no storyboards.
- There is no error printed to the console, nothing actually happens.