我对标签文本有疑问。标签文本不会显示他得到的所有文本。我放了一个 NSlog,我能够看到所有的文本,但是一些原因的标签不能。
我的代码:
-(void)viewDidLoad
{
[super viewDidLoad];
[_scroller setScrollEnabled:YES];
[_scroller setContentSize:CGSizeMake(250, 420)];
self.description = [_description stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([self.description isEqualToString:@""]) {
self.description = @"ללא תקציר";
}
[self positionLabel:self.lblTitle withText:self.stitle withY:10];
[self positionLabel:self.lblPubDate withText:self.pubDate withY:CGRectGetMaxY(self.lblTitle.frame)+10 ];
[self positionLabel:self.lblDescription withText:self.description withY:CGRectGetMaxY(self.lblPubDate.frame)+25 ];
-(void)positionLabel:(UILabel*)lbl withText:(NSString*)text withY:(CGFloat)Y
{
lbl.textAlignment = UITextAlignmentRight;
lbl.text = text;
lbl.numberOfLines = 0;
lbl.lineBreakMode = UILineBreakModeWordWrap;
CGSize size = [self calculateSize:lbl];
[lbl setFrame:CGRectMake(10 , Y , (size.width>300)?size.width:300 , size.height)];
[_scroller addSubview:lbl];
}
-(CGSize)calculateSize:(UILabel*)lbl
{
CGSize size = [lbl.text sizeWithFont:lbl.font
constrainedToSize:CGSizeMake(280, MAXFLOAT)
lineBreakMode:UILineBreakModeWordWrap];
return size;
}
编辑
这是 NSlog 文本:
和 UILabel 文本:
NSLog 中的标记文本缺少 UILabel .. 对不起语言。
什么可能导致问题?我快疯了,我什么都试过了!!提前致谢!