【发布时间】:2012-06-29 00:40:57
【问题描述】:
我希望我的文本应该右对齐。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"lisn"];
cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"lisn"] autorelease];
CGSize textSize = { 210.0, 10000.0 };
CGSize size = [[gMessageArray objectAtIndex:indexPath.row] sizeWithFont:[UIFont systemFontOfSize:12] constrainedToSize:textSize lineBreakMode:UILineBreakModeWordWrap];
UILabel *lisnerMessage=[[[UILabel alloc] init] autorelease];
lisnerMessage.backgroundColor = [UIColor clearColor];
[lisnerMessage setFrame:CGRectMake(75 ,20,size.width + 5,size.height+2)];
lisnerMessage.numberOfLines=0;
lisnerMessage.textAlignment=UITextAlignmentRight;
lisnerMessage.text=[gMessageArray objectAtIndex:indexPath.row];
[cell.contentView addSubview:lisnerMessage];
return cell
}
但我的文字没有对齐请帮助
【问题讨论】:
-
这不是对您问题的回答,而是对逻辑的评论。您确定要在每次刷新表格时为您的单元格添加一个额外的标签吗?
-
@PhillipMills:对于每个单元格,我有不同的文本,而不是该单元格中的额外文本
-
除非有代码可以从单元格中删除旧标签,否则每次调用特定索引路径时,您发布的内容总是会再添加一个标签。
-
@PhillipMills:是的,我在尝试什么?
标签: objective-c ios xcode ios5