0

Hi i want to know how to use autolayout to achieve this behavior:

  • In picture #1 is my viewcontroller contains with 3 uiview embedded with uitextview, as you can see the uiview dont allow the uitextview to show its full text.
  • So i want to know how could i use autolayout to resize the uiview in order that inner uitextview can show the full text like picture #2.

Picture #1:

enter image description here


Picture #2:

enter image description here

Rajesh Loganathan
  • 11,129
  • 4
  • 78
  • 90
mike83_dev
  • 481
  • 1
  • 6
  • 11
  • Do you have constraints set up between the UILabel and the UITextView in each of your views? You need them! – Anna Dickinson Oct 31 '14 at 11:54
  • yeah i do use autolayout in the picture #1, but i dont know what constraints are needed to let uiview expand with uitextview, uiview have a height constraint fixed to 85 – mike83_dev Oct 31 '14 at 16:54
  • Not sure if I understand -- why is it constrained to 85 if you want it to resize? – Anna Dickinson Oct 31 '14 at 20:53
  • 1
    did u solve the problem – Nischal Hada Jun 05 '15 at 06:29
  • @nischalhada apparently not. Could you please check out my problem? [link](http://stackoverflow.com/questions/43352629/how-to-add-two-uitextviews-into-a-uiview) – Bob Apr 11 '17 at 17:53
  • Hi dude can u set up the GitHub projects so that i can implement auto layout constraints to solve your problem regarding this problem – Nischal Hada Apr 12 '17 at 06:25

2 Answers2

1

Considering that the size of ui view container increases with the description text Here is an approach you can follow.Use a uilabel instead of uitextview. Structure

<UIView>
     <UILabel for header>
     </UILabel>
    <UILabel for text>
     </UILabel>
</UiView>

1)Add a top spacing constraint between header uilabel and uiview

2)Add a bottom spacing constraint between text uilabel and uiview.

3)Add a spacing constraint between 2 uilabels

3)Add a height constraint for the description uilabel .Obtain height for the uilabel based on this Adjust UILabel height depending on the text and then add the required height.

Also if you instead want fixed height for uiview then you will have to use uitextview instead of desc uilabel and add scrollable property to texview.

Community
  • 1
  • 1
rahulinaction
  • 344
  • 4
  • 14
-1

I set up a simple project that successfully resizes in iOS 8. See project on GitHub.

Chuck Krutsinger
  • 2,830
  • 4
  • 28
  • 50