2012-01-31 99 views
0

伙计,我试图实现在互联网门户上查看评论,我正在使用UITableView。注释具有结构像树,例如: - 一个评论 - 回复:第二个评论 - 回复:第二评论 ---在回复回复....在UITableView中显示评论

我试着使用自定义表格视图单元格,但它不像普通视图一样取代uilabel。我试过让字幕单元格,但替换不与cell.textLabel.bounds。

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

非常感谢。

回答

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]; 
+0

如何获得“myIndentLevel”值? – DHEERAJ 2015-07-27 05:26:14

1

对于基本结构,你可以使用的UITableViewCellindentationLevel属性,它会缩进contentView(它缩进的量取决于indentationWidth属性)