【发布时间】:2016-04-28 10:17:47
【问题描述】:
我什么都试过了
textLabel.textAlignment =NSTextAlignmentRight;
但我的代码似乎没有任何效果。在单元格内forrawatindexpath
- (UITableViewCell *)tableView:(UITableView *)myTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = (UITableViewCell *)[self.messageList dequeueReusableCellWithIdentifier:@"ChatListItem"];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"OutGoing" owner:self options:nil];
}
cell = (UITableViewCell *)[nib objectAtIndex:0];
}
textLabel = (UILabel *)[cell viewWithTag:1];
textLabel.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"chat_b2.png"]];
textLabel =[[UILabel alloc] initWithFrame:CGRectMake(21,12, 241,30)];
NSString * test=[[rssOutputData objectAtIndex:indexPath.row]xml_msg];
textLabel.text = test;
textLabel.numberOfLines = 0;
[textLabel sizeToFit];
[cell addSubview:textLabel];
return cell;
}
在这里你可以看到(红色)文本左对齐我希望它右对齐请帮我解决这个问题。
【问题讨论】:
-
你把那个标签放在哪里。 ?你在使用什么 Autolayout/AutoResizing .. ?
-
使用自动调整大小
-
此方法已过时。是时候使用 autoLayout 了。请查看apple documentation。试试看吧!
标签: ios objective-c xcode uitableview uilabel