UITableView DidSelectRowAtIndexPath?

前端 未结 5 802
余生分开走
余生分开走 2020-12-23 10:07

I have a table view with a few items (all text). When the user clicks the row I want that text in that cell to be added to an array.

How Do I grab the text out of th

5条回答
  •  一个人的身影
    2020-12-23 10:49

    Use UITableView's cellForRowAtIndexPath:

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        NSString *cellText = cell.textLabel.text;
    }
    

提交回复
热议问题