在UITableView中,cell.detailTextLabel.text无效......为什么? [英] In UITableView, cell.detailTextLabel.text isn't working… why?

查看:340
本文介绍了在UITableView中,cell.detailTextLabel.text无效......为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

tableView:cellForRowAtIndexPath:我有以下内容:

cell.textLabel.text = @"label";
cell.detailTextLabel.text = @"detail";

textLabel 按预期显示,但是尽管没有诊断, detailTextLabel 根本没有出现。我所期望的是细节文本将出现在第二行的单元格中,低于普通文本,可能是较小的字体大小。

The textLabel shows as expected, but the detailTextLabel doesn't appear at all, although there is no diagnostic. What I expected was that the "detail" text would appear in the cell on a second line, below the "normal" text, possibly with a smaller font size.

在另一个帖子中询问相同的问题,用户jbrennan回答说tableview单元格样式必须是 UITableViewCellStylePlain 以外的其他内容。但是,似乎只有两种可能的样式, UITableViewCellStylePlain UITableViewCellStyleGrouped 。我得到相同的结果(细节标签没有出现)。

The same question is asked in another posting here and user "jbrennan" answered that the tableview cell style must be something other than UITableViewCellStylePlain. However, it seems there are only two possible styles, UITableViewCellStylePlain and UITableViewCellStyleGrouped. I get the same result with either (the detail label doesn't appear).

我还没有在文档中看到另一种单元格样式吗? UITableView 上次更新中的更改和 detailTextLabel 不再可用吗?我是否必须做一些额外的事情才能让它出现?有什么建议吗?

Is there another cell style that I'm not seeing in the documentation? Did UITableView change in the last update and detailTextLabel is no longer available? Do I have to do something extra to make it appear? Any suggestions?

我正在使用xcode 3.2.5并为iPhone 4.2模拟器构建。

I'm using xcode 3.2.5 and building for iPhone 4.2 Simulator.

推荐答案

您的初始化需要更改为:

Your initialization needs to be changed to this:

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
reuseIdentifier:CellIdentifier] autorelease];

我已经强调并加粗了部分你需要改变。

I've emphasized and bolded the part you need to change.

这篇关于在UITableView中,cell.detailTextLabel.text无效......为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆