Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Simple iPhone App with Objective-C Views and View Controllers IBOutlet

David O.
David O.
935 Points

I have a longer text than the default words, and it got cut off during the simulation when I pressed the button?

How to solve this problem? Thanks

2 Answers

Michael Liendo
Michael Liendo
15,326 Points

I would keep the size of the label the same, and adjust the label's text accordingly. To do that, in your storyboard you would set the lines property to 0 in the attribute inspector, what this does is automatically gives you the appropriate number of lines. But in order for it to work, you would want to change the auto shrink property (a couple lines below the lines property) from Fixed Font Size to minimum font size. The value in there is a scaling factor. It's 0 by default, but if you put in something like 0.5, that means it'll dynamically size your text to a minimum of whatever the current font size is.

Hope that helps, thank you for the upvote, and happy coding!

David O.
David O.
935 Points

This is great, it works! Thanks for helping! :)

Michael Liendo
Michael Liendo
15,326 Points

Not sure exactly what you mean. Is it that the text you're trying to display is longer than the length of the label? If so, you can increase the number of rows that your label can display in the attributes inspector in your storyboard.

David O.
David O.
935 Points

Yes, the label text, before pressing the button it shows "The interesting fact!" after pressing the button, it shows "There's another interesting...". I increased the label size and it's showing up correctly now, but is there a way to make the label auto expand when there are more text?