[英]UITableView detailTextLabel - iphone development
why is "detailTextLabel" not working anymore? 为什么“ 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;
}
Try to change the style of the cell, use this code while initializing the cell 尝试更改单元格的样式,在初始化单元格时使用此代码
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] autorelease];
For more information about the cell styles look at the apple's class reference 有关单元格样式的更多信息,请参阅苹果的类参考。
You've chosen a cell style UITableViewCellStyleDefault
that does not support a detailTextLabel
您选择的单元格样式
UITableViewCellStyleDefault
不支持detailTextLabel
Try using a different style. 尝试使用其他样式。
edit 编辑
You choose a style in the initWithStyle:reuseIdentifier;
您可以在
initWithStyle:reuseIdentifier;
选择一种样式initWithStyle:reuseIdentifier;
method. 方法。 Have a look at the UITableViewCell docs which describes the available cell styles.
看一下UITableViewCell文档,其中介绍了可用的单元格样式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.