views:

123

answers:

1

Hi, am being driven crazy trying to obtain how many lines a string will require as entered in a UITextView.

The code below for some reason does not split the string supplied over lines and returns a stringSize = (o, 32) WTF?

I enter a crazy long string that is way past 320 but still no expected result?

NSString *t = @"in my app this string is a long line of text......";

CGSize stringSize;

UIFont *f = [UIFont fontWithName:@"Heiti SC" size:30];

stringSize = [t sizeWithFont:f forWidth:320.0f lineBreakMode: UILineBreakModeWordWrap];

HELP .... please

A: 

Try the next line:

stringSize = [t sizeWithFont:f constrainedToSize:CGSizeMake(320, 10000) lineBreakMode:UILineBreakModeWordWrap];

It works for me.

If it doesn't work then try to change the font to:

UIFont *f = [UIFont systemFontOfSize:30];
Michael Kessler
cha ching ;-)))) thanks
user7865437