2010-08-03 40 views
0

如何將標籤和文本文件添加到UITableview中的每一行。我可以通過接口生成器添加它還是必須在代碼中執行,如何添加標籤和文本文件到UITableview中的每一行

謝謝, 山姆。

+1

我這樣做了,但你應該投票答案很好(在你之前的問題中有很多),並在提出任何問題之前接受。 – taskinoor 2010-08-03 11:26:11

回答

2

您可以自己製作自定義表格視圖單元類,也可以使用built-in cell styles之一。例如,Apple的「設置」面板使用UITableViewCellStyleValue1

然後,您將detailTextLabel設置爲文本,並將子視圖(您的文本字段)添加到您的單元格的contentView。

static NSString *CellID = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID]; 

if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellID] autorelease]; 
} 

cell.detailTextLabel.text = @"a title"; 
[cell.contentView addSubview: xyz]; // xyz = your text field 
相關問題