How to properly dismiss a ViewController in Swift: modal and push methods
Hello everyone! I'm a beginner in iOS development and writing my first app in Swift. I have two screens: the first one (MainViewController) and the second one (DetailViewController). I navigate from the second to the first using a "Back" button, but nothing works.\n\nHere's my code:\n\n```swift\n// MainViewController.swift\nimport UIKit\n\nclass MainViewController: UIViewController {\n \n override func viewDidLoad() {\n super.viewDidLoad()\n let button = UIButton(type: .system)\n button.setTitle("Open details", for: .normal)\n button.addTarget(self, action: #selector(openDetail), for: .touchUpInside)\n button.frame = CGRect(x: 100, y: 100, width: 200, height: 50)\n view.addSubview(button)\n }\n \n @objc func openDetail() {\n let detailVC = DetailView
No answers yet.
Log in to leave an answer