2

I googled but have not found working solution, I have UIScrollView adding inside UITextField and UIButtons with NSLayoutConstraint, I don't use storyboard and setting everything programmatically

my issue is: can't calculate dynamic height of UIScrollView.contentSize because I am using AutoLayout also tryed UIScrollView.layoutIfNeeded() but no luck

can any one guide or advice me how to to get it work?

Hattori Hanzō
  • 2,349
  • 4
  • 19
  • 36

2 Answers2

4

@DonMag's comment was right solution to my problem stackoverflow.com/a/44933358/6257435

if you have in UIScrollView objects with AutoLayout don't forget add .bottomAnchor to last item

Hattori Hanzō
  • 2,349
  • 4
  • 19
  • 36
0

Sum of scrollview subview’s height and constraint constants is the final height. Even after constraints layed out, it’s always summ. So just calculate it, and you height. But why do you need calculating scrollview’s content height? If it’s adjusting wrong, set your subviews height constraints, top and bottom contraints to scrollview, and content size will be calculated automatically