1
I would like to know how to use didSelectRowAtIndex
, more specifically I would like to know how each Row of my UITableView
calls a ViewController
specifies. In my code below, in case would like each item of the array who is in the UITableView
call another ViewController
.
class ViewControllerAnalise: UIViewController, UITableViewDataSource, UITableViewDelegate {
var formulas = ["Participaçao de Capital de Terceiros", "Composiçao do Endividamento", "Imobilizaçao do Patrimonio Liquido", "Liquidez Geral", "Liquidez Corrente", "Liquidez Seca", "Giro do Ativo", "Margem Liquida", "Rentabilidade do Ativo", "Rentabilidade do PL"]
override func viewDidLoad() {
super.viewDidLoad()
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! ViewControllerCell2
cell.formula.text = formulas[indexPath.row]
return cell
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return formulas.count
}
}
In this case Voce passed the value of the cell to the second screen right? , in the code I posted has an array with 10 elements, I wanted when I clicked on each of the elements to open a different viewcontroller, in this case I have 10 viewcontrollers,and each element calls one. I don’t understand the detail. I’m sorry but I’m still getting started
– Eduardo Bonfa
Okay, I made the changes to my answer to suit your case.
– Paulo Rodrigues
Thank you very much, it worked out here, :)
– Eduardo Bonfa
Perfect, if this answer has been helpful, consider mark it as settled, so help others with the same doubt and community :)
– Paulo Rodrigues
Really, can you leave the other code here tbm? to send the indexPath.Row to another viewController
– Eduardo Bonfa
Yes, thence inside each
ViewController
you will need a variable of typeInt
, and then just define, for example,viewController.itemIndex = indexPath.row
before giving the push.– Paulo Rodrigues
Thank you very much, where I put the question as resolved?
– Eduardo Bonfa
To mark an answer as accepted, click the checkmark next to the answer to switch from gray to green color.
– Paulo Rodrigues