Getting a line count woes UITextView
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
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];
精彩评论