Jump to content

Xcode and Swift

TonyStark

Good day to all. I'm creating a new iOS app and I want to use dynamic table cells....I would like to ask how can I make the tap of each cell to navigate to a certain ViewController. In static cells it was relatively easy...Any thoughts or ideas on how to make this happen to Dynamic Content. It seems to have a difference on how to do it. I'm coding in Swift.

Link to comment
Share on other sites

Link to post
Share on other sites

It depend. Does each cell need to send to the same viewcontroller but different data? or does they send to different viewcontroller?

Link to comment
Share on other sites

Link to post
Share on other sites

1) Create as many prototype cells that you need.

 

2) drag from each of them to the view that you want and name the segue with a lowercase version of the array you created for your tableview.

   

 

3)Now go into you ViewController for the tableview and create a new func with all the code.

             

Here is the function:

  func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {        if (indexPath.row == 0){            self.performSegueWithIdentifier("yourseguename", sender: tableView)        }

Do this for each of the segues but change the segue name in the function to the new segue name and change the index row to what row the Cell is on your tableview. For example if you can a second one the indexrow would now be 1.  Rember you start at 0 when counting arrays.

 

 

Here is a sample project if you want: https://www.dropbox.com/sh/wn7wamqdp4ty34h/AADxXGMByvvaUYfzsBZ2Ej1Oa?dl=0

 

Ask me if you have any other questions.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×