I have a problem with the UILabel
sizeToFit
method:
UILabel *questionLabel = [[UILabel alloc]initWithFrame:CGRectMake(0,0,320,320)]; questionLabel.lineBreakMode = UILineBreakModeWordWrap; questionLabel.backgroundColor=[UIColor clearColor]; questionLabel.textAlignment=UITextAlignmentLeft; questionLabel.textColor=[UIColor blackColor]; questionLabel.tag=1; questionLabel.font=[UIFont systemFontOfSize:13]; questionLabel.numberOfLines = 0; [questionLabel sizeToFit]; [myView addSubview:questionLabel];
I wrote this code to display my data. But if I write: [questionLabel sizeToFit]
my data is not displayed correctly. If I delete [questionLabel sizeToFit]
, then it will be displayed, but only half of the data will be displayed.
Thanks and respect.
source share