0
表格單元格的左側應該有3個文本行(可以說標題,名稱,dob)和右側大小(分數)的文本行。使用故事板自定義表格單元格
行數自動生成以及每個單元格的內容。
我試圖在故事板中的原型單元格內創建帶有標籤的UILabels,並填充這些標籤的文本,但只有空單元格纔會顯示無內容。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(!cell){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
UILabel *titleLabel = (UILabel *)[cell viewWithTag:100];
titleLabel.text = list.title;
UILabel *nameLabel = (UILabel *)[cell viewWithTag:101];
nameLabel.text = list.name;
UILabel *dobLabel = (UILabel *)[cell viewWithTag:102];
dobLabel.text = list.dob;
UILabel *scoreLabel = (UILabel *)[cell viewWithTag:103];
scoreLabel.text = list.score;
return cell;
}
我的代碼有什麼問題/有沒有其他解決方案?
謝謝你的時間和幫助。
對!我沒有在故事板中設置單元格標識符。謝謝! – B1z