![](/img/trans.png)
[英]UITableView, registerClass and detailTextLabel — strange behavior
[英]UITableView detailTextLabel - iphone development
为什么“ detailTextLabel”不再起作用?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
cell.textLabel.text=[listData objectAtIndex:[indexPath row]];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
cell.detailTextLabel.text=@"hi";
return cell;
}
尝试更改单元格的样式,在初始化单元格时使用此代码
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] autorelease];
有关单元格样式的更多信息,请参阅苹果的类参考。
您选择的单元格样式UITableViewCellStyleDefault
不支持detailTextLabel
尝试使用其他样式。
编辑
您可以在initWithStyle:reuseIdentifier;
选择一种样式initWithStyle:reuseIdentifier;
方法。 看一下UITableViewCell文档,其中介绍了可用的单元格样式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.