A
A
Alex Ananchenko2020-01-01 19:32:42
iOS
Alex Ananchenko, 2020-01-01 19:32:42

How to make different value in uitableview cell?

Hello. I have a table, when I click on a cell, it moves to the next table. But when I set the value for the cells of the second table, all all cells have the same text. For example, if I clicked on the first cell of the first table, a table should open with the values: 1, 2, 3; if I click on the second cell of the first table, a table should open with the values: 4, 5, 6, etc. Thanks to all.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Vorobei, 2020-01-01
@AeLxI

Most likely you need to handle the didSelectRowAt method of the UITableViewDelegate protocol .

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
     switch indexPath.row {
     case 0:
         // Сделать что-то по нажатию на ячейку с индексом 0
         break
     case 1:
         // Сделать что-то по нажатию на ячейку с индексом 1
         break
     default:
         break
     }
}

You can see more in my video about tables.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question