我已經試過一切都像的UILabel視圖不對齊到右
textLabel.textAlignment =NSTextAlignmentRight;
但沒有什麼似乎工作波紋管是我的代碼。裏面cellforrawatindexpath
- (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 ..? –
使用AutoResizing –
此方法已過時。它使用autoLayout的時間很長。請檢查[apple文檔](https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/)。試試吧! – GoGreen