Open new View Controller by clicking Cell in Table View – Swift iOS

Programmatically:

let destination = UIViewController() // Your destination
navigationController?.pushViewController(destination, animated: true)

Storyboard:
First you’ll have to set an identifier for your view. In the screenshot below you can see where to enter the identifier.

screenshot

After that, you can create a “destination” and push it to the navigation controller by using the code below:

let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
let destination = storyboard.instantiateViewController(withIdentifier: "YourViewController") as! YourViewController
navigationController?.pushViewController(destination, animated: true)

Segue:
First you’ll have to set an identifier for your segue as shown below:

segue1

segue2

performSegue(withIdentifier: "segue", sender: self)

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "segue" {
        // Setup new view controller
    }
}

EDIT: Updated for Swift 3.x

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)