hello
I am using Textview which has dynamic any length data. i want to set the size of scrollview to more than the size of Textview.
How can i set the size of scrollview as the size of Textview ?
Thanks in Advance ....
hello
I am using Textview which has dynamic any length data. i want to set the size of scrollview to more than the size of Textview.
How can i set the size of scrollview as the size of Textview ?
Thanks in Advance ....
Some time ago I've found the following Code on the Internet and it works very well:
- (float) calculateHeightOfTextFromWidth:(NSString*) text: (UIFont*)withFont: (float)width :(UILineBreakMode)lineBreakMode
{
[text retain];
[withFont retain];
CGSize suggestedSize = [text sizeWithFont:withFont constrainedToSize:CGSizeMake(width, 1000.0) lineBreakMode:lineBreakMode];
[text release];
[withFont release];
NSLog(@"%f", suggestedSize.height);
return suggestedSize.height;
}
I use this in my own app like this:
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, [self calculateHeightOfTextFromWidth:thetext :[UIFont fontWithName:@"Helvetica" size:17.0] :320 :UILineBreakModeWordWrap]);