Here's one for the "What-the-****-is-it-now?" department. I have a simple view that has some details about my iOS app that I want to display when a toolbar button is touched. The UIViewController is called "AboutViewController". I put a view controller into a storyboard and set its class to AboutViewController. Here's the toolbar button code in the superview controller that loads it:
let aboutVC = storyboard.instantiateViewController(withIdentifier: "About")
aboutVC.view.frame = CGRect(x: 0.0, y: 0.0, width: 200, height: 300)
self.view.addSubview(aboutVC.view)
aboutVC.view.center = self.view.center
I put a "Dismiss" button into the controller instance in the storyboard and connected it to this code in AboutViewController:
@IBAction func dismissButton(_ sender: Any) {
self.view.removeFromSuperview()
print("Dismiss button touched.")
}
When I press the toolbar button, the subview is displayed in the centre of the superview, just as I expected. But when I press the Dismiss button in the subview, nothing happens. The message isn't printed either. I've checked and rechecked that the connection between the button and the IBAction is set.
It seems to me I've done this same damned thing many times before and had no problem. What the **** is wrong now?