在UITableView中显示评论

时间:2012-01-31 12:48:36

标签: iphone objective-c ios xcode uitableview

伙计们,我正在努力实现在互联网门户网站上查看评论,我正在使用UITableView。注释具有树的结构,例如: - 一条评论 - 回复:第二条评论 - 回复:第二条评论 ---回复回复....

我尝试使用自定义表格视图单元格,但它并不像普通视图那样替换uilabel。我试图制作字幕细胞,但替换不适用于cell.textLabel.bounds。

你有什么想法吗? 我有NSDictionary中所有评论的作者姓名,评论级别和评论文本。

非常感谢。

2 个答案:

答案 0 :(得分:1)

对于基本结构,您可以使用indentationLevel的{​​{1}}属性,该属性将缩进UITableViewCell(缩进量取决于contentView属性)< / p>

答案 1 :(得分:1)

将UILabel添加到表格视图单元格,然后根据缩进级别设置标签的框架。例如:

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

myLabel = [[[UILabel alloc] initWithFrame:CGRectMake(10*myIndentLevel, 0, 320-(10*myIndentLevel), 25.0)] autorelease];

myLabel.text = @"the comment text";

[cell.contentView addSubview:myLabel];