Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

electronica

macrumors newbie
Original poster
Sep 24, 2011
17
0
hi, i have a problem about changing the size of textview.

Code:
UITextView *yazi = [[UITextView alloc] initWithFrame:CGRectZero];
    yazi.text = [NSString stringWithContentsOfFile:hayat encoding:NSUTF8StringEncoding error:nil];
    [yazi setFrame:CGRectMake(0, 245, 320, yazi.contentSize.height)];

scrollview.contentSize = CGSizeMake(320, yazi.contentSize.height);


i try to create a textview programatically. Than fill it from different txt files for every row selected in my table. i want to make my scrollview's height equal to textview's height.

well, basically how can i make a textview's height to fit exactly to the text size.

thanks for helps.
 
Last edited by a moderator:
Do you know the superclass of UITextView?

You can use the methods in UIStringDrawing.h to determine the rectangle that will enclose a text string. sizeWithFont: etc. You can set the frame of your view to the appropriate size based on the result of sizeWithFont:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.