我的标签超出了应用程序框架:
只有当我滚动时,我才能看到其余部分:
[_scroller setScrollEnabled:YES];
[_scroller setContentSize:CGSizeMake(320, 600)];
self.description = [_description stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[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)+10 ];
}
-(void)positionLabel:(UILabel*)lbl withText:(NSString*)text withY:(CGFloat)Y
{
lbl.textAlignment = UITextAlignmentRight;
lbl.text = text;
lbl.numberOfLines = 0;
lbl.lineBreakMode = NSLineBreakByWordWrapping;
CGSize size = [self calculateSize:lbl];
//FIXED
[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;
}
什么会导致这个问题?xib中的标签可能相关?