Note that there are some explanatory texts on larger screens.

plurals
  1. POUITextView not Resizing for iPhone
    text
    copied!<p>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 <a href="https://stackoverflow.com/questions/50467/how-do-i-size-a-uitextview-to-its-content">How do I size a UITextView to its content?</a> 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. </p> <pre><code>//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; } </code></pre> <p>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?</p> <p><strong>edit:</strong> 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?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload