0
一個按鈕動作我有一個按鈕,一個文本字段和表視圖。我想要的是當我在文本框中輸入一些文本並單擊按鈕(名爲update)時,它應該更新tableviewcell的detailtextlabel。更新的tableview爲textLabel使用Xcode中
一個按鈕動作我有一個按鈕,一個文本字段和表視圖。我想要的是當我在文本框中輸入一些文本並單擊按鈕(名爲update)時,它應該更新tableviewcell的detailtextlabel。更新的tableview爲textLabel使用Xcode中
試試這個,點擊按鈕添加[yourtableview reloadData]
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell==nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
else
{
for(UIView *v in cell.contentView.subviews)
{
[v removeFromSuperview];
}
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;;
cell.accessoryType = UITableViewCellAccessoryNone;
[[cell textLabel] setFont:[UIFont fontWithName:@"Verdana" size:10]];
cell.textColor = [UIColor whiteColor];
cell.text = textfield.text; //Yourtextfield text
return cell;
}
後