我有一个表视图有几个项目(所有文字)。当用户单击行时,我想要将该单元格中的文本添加到数组。
如何从单元格中抓取文本?
我已经有了:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { }
解决方法
使用
UITableView
‘s cellForRowAtIndexPath:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; Nsstring *cellText = cell.textLabel.text; }