0

I a trying to create a UIScrollView that fits exactly the contents of its subviews. I do this with a StackView and the scroll view's height is determined by how much content there is in the stack view. Within the stack views, there are views that contain an UIImageView and a UITextView enter image description here

The UIScrollView starts below the title view, however every time I want to add another view (which it should scroll when the content is bigger than the actual frame) there is an issue with the scroll view's Y position. This works perfectly if I only add UILabels and UITextFields, using the same procedure

enter image description here

How can I do it so I can programmatically add views on the stack view that includes an UIImageView and a UITextView, just as the View Controller with labels and textfields does.

You can download my app project at the following url https://github.com/francisc112/DescriptionWithImageApp.git

ishwardgret
  • 1,068
  • 8
  • 10
Francisco Ruiz
  • 209
  • 3
  • 12

2 Answers2

0

Instead of a scroll view why don't you use a table view and create a custom cell with the stackview and its contents inside the cell and you can dequeue the same cell for adding multiple information.

Sarvad
  • 171
  • 3
  • 12
0

I was not able to open your project

enter image description here

So I Tried opening your StoryBoard and Re-Viewing your constraints Applied , here is what I have Done Please check in following Link

Link - https://drive.google.com/file/d/1D-dzKsSqpx7dWsI5fYRdAfCMY_vENoIR/view?usp=sharing

View Hierarchy enter image description here

Note - For such output I will prefer using a TableView instead of StackView as Same output can easily be achieved using TableView

iOS Geek
  • 4,825
  • 1
  • 9
  • 30