Tag: detailtextlabel

为什么我的UITableViewCell不能在任何样式中显示detailTextLabel?

这个让我把头发拉出来。 我只是试图创build一个UITableViewCellStyleSubtitle风格的表格,文字和细节。 但细节没有显示出来。 通常这是因为有人忘记了用正确的样式来初始化单元格,但在这种情况下不是这样。 我已经尝试了所有四种单元格样式,并且其中的任何一个都没有显示细节,但是当我使用UITableViewCellStyleValue2时,文本标签确实移到了右侧。 我已经成功创build了多次表。 在这种情况下,我能想到的唯一明显的区别是我没有使用UITableViewController。 相反,我像任何其他视图一样embeddedUITableView,并连接我自己的数据源和委托。 我已经find了关键的方法: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // Get the UITableViewCell (out of the recycling pool, or de novo) NSString *reuseID = @"CELL"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseID]; if (not cell) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:reuseID] autorelease]; } cell.textLabel.text = @"Foo"; cell.detailTextLabel.text = @"Bar"; […]