代码之家  ›  专栏  ›  技术社区  ›  Joshua

UITableViewCellStyleValue1的问题

  •  2
  • Joshua  · 技术社区  · 16 年前

    我有以下代码:

    static NSString *CellIdentifier = @"Cell";
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
    
    cell.textLabel.text = @"Publisher";
    cell.detailTextLabel.text = @"This Is A Very Very Long String";
    

    其结果如下所示:(只有第一个表行相关)

    alt text

    看起来,细节文本与“发布”标题重叠,因此两个字符串都被截断。 我希望“发布”标题neverc被截断如下:

    alt text

    使用UITableViewCellStyleValue1是否可以实现这一点?我看到很多帖子建议创建自定义单元格,但这真的是唯一的方法吗?

    谢谢 乔希

    2 回复  |  直到 16 年前
        1
  •  0
  •   Vladimir    16 年前

    你可以试着设置 adjustsFontSizeToFitWidth 属性将单元格的标签设置为“是”和“是” minimumFontSize 属性设置为适当的值。如果没有帮助的话——看起来你确实应该使用自定义单元格。

        2
  •  0
  •   DenVog    15 年前

    我意识到这篇文章已经过了一段时间,所以SDK可能已经对这项功能进行了更新。我在Xcode v4中找到了什么。1是UITableViewCellStyleValue1,现在按您的意愿执行。文本标签。文本不会截断。

    使用UITableViewCellStyleValue2将截断标题。 Where the doc suggests

    它的功能是为文章中的重要信息提供标题或说明 更突出的左对齐细节文本标签。

    推荐文章