清除UITableView中单元格的值
问题描述:
如何清除UITableView cell.detailTextLabel.text中的内容?一旦用户点击顶部的左侧栏按钮,我想要清除所有答案?清除UITableView中单元格的值
以下是我的代码。不知道这是否是正确的方法。
-(void)ClearBtn:(id)sender {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.detailTextLabel.text = @"test";
//NSLog(@"cell %@", cell.detailTextLabel.text);
[self.tableView reloadData];
}
答
如果你不想删除的单元格,可以添加以下代码表
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
int flag = 0;
UIButton *recipient = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:indexPath];
oldCell.textLabel.text = @"";
}
的委托而如果你想删除的所有内容,你可以只是一句你数据源变量并简单地重新加载表格。
希望t适合你!