Your parent view seems to be a scroll view, and it is missing the constraints that tell it what its scrollable content size is (note the warning in your first screenshot). Since nothing is defining the content size, the scrollable area size is therefore just zero.
I'm not sure what constraints you need exactly as that depends on the details of your situation, but in order to at least see your subview you could add (for example) equal-width and equal-height constraints to your subview and its parent view (the scroll view):
NSLayoutConstraint.activate([
subview.widthAnchor.constraint(equalTo: parent.widthAnchor),
subview.heightAnchor.constraint(equalTo: parent.heightAnchor)
])
This defines the scrollable area as being equal in width and height to the scroll view's frame. However, if you do this then there won't really be any kind of scrolling other than the bouncing behavior when you try to scroll beyond the scrollable area (if that's turned on for this scroll view).
You could instead change the height anchor to be equal to some constant, just to allow for some actual scrolling:
NSLayoutConstraint.activate([
subview.widthAnchor.constraint(equalTo: parent.widthAnchor),
subview.heightAnchor.constraint(equalToConstant: 2000) // just some arbitrary amount for demonstration purposes
])
This makes the scrollable height equal to 2000 points, regardless of the height of the scroll view's frame.
Or, if you want the scrollable area to be some multiple of the scroll view's frame height, you could set a multiplier on the height anchor:
NSLayoutConstraint.activate([
subview.widthAnchor.constraint(equalTo: parent.widthAnchor),
subview.heightAnchor.constraint(equalTo: parent.heightAnchor, multiplier: 3)
])
This makes the scrollable height equal to three times the height of the scroll view's frame.
And if you want a horizontally-scrolling scroll view, just change the widthAnchor
instead of the heightAnchor
like I've done above. Or if you want a 2D-scrollable area that lets you pan around both vertically and horizontally, then change both.