Nurdin
Nurdin

Reputation: 23883

Programmatically switching views using UITableView in Swift

I can't switch to another view controller using UITableView. My code is like below.

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        tableView.deselectRowAtIndexPath(indexPath, animated: true)

        let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)

        let dashViewController = storyBoard.instantiateViewControllerWithIdentifier("menuView") as DashViewController
        self.presentViewController(dashViewController, animated:true, completion:nil)

    }

enter image description here

I click one of my cells, and it just does nothing.

Upvotes: 0

Views: 424

Answers (1)

Nurdin
Nurdin

Reputation: 23883

I already found the answer, I forgot to put UITableViewDelegate.

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{

}

And assign tableview with view controller

enter image description here

Upvotes: 1

Related Questions