0
votes

I decided to write new question on the topic after reading a lot of information here and there and trying to succeed with no results.

The task looks trivial. I have ScrollView. It has one subview of type UIView (let's call it ContentView). Content view, in turn, has 2 subviews of type UIView (let's call it ViewA and ViewB).

-ScrollView
    -ContentView
        -ViewA
        -ViewB

ScrollView has 4 constraints which bound it to all edges of superview. ViewA has 3 constraints (to ContentView) - top, left and right. ViewB has 4 constraints (to ContentView) - bottom, left, right and height. There is another constraint between bottom of ViewA and top of ViewB. The idea is that I will change the frame of ContentView at runtime, and ViewA and ViewB will be sized and layout accordingly and automatically.

Well, it does not work. I tried to put different constraint from ContentView to ScrollView, tried without them. Got different results, but none of them was correct. For example, ContentView has 4 constraints to ScrollView (top, bottom, left and right). I am setting the Frame of ContentView at runtime. However, it gets reset, and eventually, ContentView frame has basically the height of ViewB (which has height constraint).

Your help is much appreciated.

1

1 Answers

0
votes
  1. Don't set the frame of the content view.
  2. You need to add a constraint to viewA in such a way that will define its height.