I've published an app for the iPad and I'm working on making it universal. I have a UITextView that I want to resize to fit its contents. The TextView is created via storyboard and referenced through an IBOutlet. I read the answer to this question How do I size a UITextView to its content? and am using the code to resize the TextView. This code works perfectly on the iPad, but when I run it on the iPhone, it doesn't resize. I've been working on this problem for many hours, and it has been killing me.
//self.speciesDescription is the TextView in Question here:
//set the text
self.speciesDescription.text=[self.modal getdescriptionForSpecies:self.plantDisplayed];
//call the method below
[self resizeTextView:self.speciesDescription];
//resizes the text view to fit the text
-(void)resizeTextView:(UITextView *)textView {
CGRect contentFrame=textView.frame;
contentFrame.size.height=textView.contentSize.height;
textView.frame=contentFrame;
}
If I call initWithFrame: on the TextView before trying to resize it works fine, but it would save me bunches of time and code if I don't have to do this. Doesn't the StoryBoard call initWithFrame: automatically anyways?
edit: I ran some tests today and realized that the contentSize property of the textView always has a width of 0 and the height is over 16000. Any ideas why that might be?