0

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.

6
  • Have you stepped through it? Is your didSelect... method getting called? Commented Jan 28, 2015 at 3:34
  • if you print something inside the didSelectRowAtIndexPath do you get any output when you click? Commented Jan 28, 2015 at 3:35
  • wait, i try first. wait. Commented Jan 28, 2015 at 3:37
  • I already print out something , no output. NSLog("Clicked!!") Commented Jan 28, 2015 at 3:44
  • did u set the delegate self.tableView.delegate = self ? Commented Jan 28, 2015 at 4:04

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.