2011-02-28 67 views
0

如何清除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]; 
} 

回答

0

如果你不想删除的单元格,可以添加以下代码表

- (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适合你!