0

I want to implement User setting in a view controller which has many fields whose height is greater then the default height of view controller. I know I can increase the size of view controller by changing simulated size to freedom and increasing it to my desired height.

But when I do that my scroll will work only till the default height but not up to the increased height.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • you can implemented scrollview/table view – Axel Jan 08 '17 at 14:06
  • I tried with scrollview but it din't work. By Table view you mean adding it programmatically or by static way.. –  Jan 08 '17 at 14:10
  • Yes, you can use scroll view, but make sure you define the fully qualified auto layout constraints of the scroll view's subviews to control the content size of the scroll view. E.g. In equivalent VFL: `V:|-[label1]-[label2]-...-[label23]-|`. If you're missing that last one (last control to bottom of scroll view), the content size will not be set for you. – Rob Jan 08 '17 at 14:11
  • Perhaps even easier, use static table view. – Rob Jan 08 '17 at 14:12
  • scroll view is easy to implement, you just need to set proper constraints. I don't know, how you want it to look like. Always if you want to display something that is bigger than your view in ViewController, you should use ScrollView. TableView(static or dynamic) implements ScrollView. – Axel Jan 08 '17 at 14:15
  • If you are trying to do this in a Storyboard, look at this question and its duplicate: http://stackoverflow.com/q/39301896/1630618 – vacawama Jan 08 '17 at 14:17
  • hi @vacawama I tried to implement it with the link you sent, But problem is not solved, I'm using Xcode 8 is it applicable for that? –  Jan 08 '17 at 14:59
  • It should be fine in Xcode 8. Did you pin it the way I suggested and how are you setting the size of your contentView? – vacawama Jan 08 '17 at 15:02
  • I'm new swift, I did it By selecting the content view and in view->show Frame rectangle and and increasing height to 1136. –  Jan 08 '17 at 15:10
  • Give it it an explicit height constraint, or Autolayout will shrink it based upon the constraints of the views inside it. Alternatively, if you make sure all of the views inside the contentView are connected to each other and the top one is connected to the top of the contentView and the bottom one is connected to the bottom of the contentView, and all of their heights are set, then the contentView size will be determined as the height of all of the subviews. – vacawama Jan 08 '17 at 15:30

0 Answers0