How to get the cell.label.text values from a selected row of UITableview?

后端 未结 2 874
难免孤独
难免孤独 2021-01-22 09:51

I am new in iOS application Development and i need help on UItableview. As i am populating the table-view with json data.I am also Using Customized Tableviewcell also. I am not

相关标签:
2条回答
  • 2021-01-22 10:04

    In Swift

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    
           let cell = tableView.cellForRow(at: indexPath) as! NotesCell!
            let value = cell?.lblDetail.text
        }
    
    0 讨论(0)
  • 2021-01-22 10:06

    You may have to implement the method:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    

    which is called each time a row is selected, and inside that method:

    Simpletablecell *cell = (Simpletablecell *)[tableView cellForRowAtIndexPath:indexpath];
    lbluid.text = cell.lbl4.text;
    

    The method:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    

    is called the the table view is loading it's cells to be displayed, which is why you lbluid.text is only changing when the table view is scrolled.

    0 讨论(0)
提交回复
热议问题