I have the code as below for my UITextView set up.
CGRect itemDescFrame = CGRectMake(20, 160, 280, 200);
UITextView *itemDesc = [[UITextView alloc] initWithFrame:itemDescFrame];
...
itemDesc.editable = NO;
itemDesc.scrollEnabled = NO;
...
I have disabled the UITextView scroll bar, however some of the content on the bottom is being hidden. How can I set the UITextView height to fit to the content height?
Thanks
UPDATE:
NSLog(@"frame %@", itemDesc.frame.size.height);
NSLog(@"content %@", itemDesc.contentSize.height);
Result:
2011-10-11 11:00:18.010 abc[1606:207] frame 200.000000
2011-10-11 11:00:18.010 abc[1606:207] content 200.000000
As a subclass of
UIScrollView,UITextViewhas a property calledcontentSizewhich, in the case of aUITextView, should be the size that the text occupies after it is is placed in the view. Try setting the height of the text view’s frame to the height ofcontentSize.