sizeWithFont returns wrong heigth value
Hi! I've a little problem. I need a multiline text with a dynamic content, so i have to set a content of a UITextView via code. The problem is that the heigth returned by sizeWithFont:constrainedToSize:lineBreakMode: is not perfetc at all, is often smaller a little bit. Let see an example:
Then, string1 appears, but not at all. It seems that the aTextView is too short to contain all the words. Where's the problem?
NSString *string1 = @"Hi to all!I've this question for you, and i hope you can help me";
CGSize maxSize = CGSizeMake(320.0, 1000.0);
UIFont *font = [UIFont fontWithName:@"Helvetica-Bold" size:20.0];
CGSize textSize = [[string1 sizeWithFont:font constrainedToSize:maxSize lineBreakMode:UILineBreakModeWordWrap];
NSLog(@"Frame at indexPath %d: heigth %f width %f", indexPath, textSize.width, textSize.width);
CGRect textViewFrame = CGRectMake(0.0, 0.0, textSize.width, textSize.height);
UITextView *aTextView = [[UITextView alloc] initWithFrame:textViewFrame];
aTextView.text = string1;
aTextView.font = [UIFont fontWithName:@"Helvetica-Bold" size:20.0];
aTextView.userInteractionEnabled = NO;
Then, string1 appears, but not at all. It seems that the aTextView is too short to contain all the words. Where's the problem?
MacBook Pro 2,4 Ghz 15,4", Mac OS X (10.5.3)