0

Hi i googled around a bit and didn´t find any solutions for my problem. i fill a UILabels text with a large String, and sometimes (it doesn`t do so everytime) my UILabel.text is incomplete (not the whole NSString). It mostly happens with very large Strings but also with shorter ones.

Has anybody had that problem, or does know a workaround for this? I really don`t know why this is happening...

Hint: I am using IB with a UILabel on a ScrollView. In the ViewDidLoad Method of the View i figure out the height of the UILabel with the sizeWithFont Method. I use WordWrap, AlignBaseline for my UILabel in IB

user476567
  • 21
  • 3

2 Answers2

1

i did change my method for the expected size to this:

UIFont *labelFont           = [UIFont systemFontOfSize:14];
CGSize expectedLabelSize    = [testString sizeWithFont:labelFont 
                                  constrainedToSize:maximumLabelSize 
                                      lineBreakMode:UILineBreakModeWordWrap];

this was wrong:

CGSize expectedLabelSize    = [testString sizeWithFont:IBOutletUILabel.font 
                                  constrainedToSize:maximumLabelSize 
                                      lineBreakMode:UILineBreakModeWordWrap];

cobbal is right...

but i am confused, because it seemed to be ignoring the newline characters before, cause my label size was variating

user476567
  • 21
  • 3
0

Make sure you set the numberOfLines to 0 in addition to setting word wrapping.

cobbal
  • 69,903
  • 20
  • 143
  • 156
  • hi ive already word wrapping and set numberOfLines to zero. both in Interface Builder, now i`ll try to set it programmatically. and see whats going to happen. – user476567 Dec 16 '10 at 16:03
  • @user It might also be related to this question: http://stackoverflow.com/questions/1204000/iphone-uilabel-sizewithfont – cobbal Dec 16 '10 at 20:43