0

I have a ArrayAdapter and when you click one item, it takes you to a detail page,

image

label

textview

laid out like that.

Since I have to make a API call to get the info for the label/textview. The height of the content view that the scrollview is based off of.

whats the best approach to making variable scrollviews that follow a template. But also have a load time.

rmaddy
  • 314,917
  • 42
  • 532
  • 579

1 Answers1

0

After you get the API response (it probably has a delegate or a block to get when the response arrives), you should recalculate the label and the textView heights.

To calculate the label and textView heights, iOS has some methods that returns the expected size of a label according to its content and its font. You should check this post: How to calculate UILabel height dynamically?.

Then you have to set the content size of the scrollView (not the size of the scrollView itself). To achieve that, use setContentSize. You should set the correct height by summing up all of its subviews heights.

Hope this helps!

Community
  • 1
  • 1
Leandro Fournier
  • 927
  • 1
  • 9
  • 21