Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
570 views
in Technique[技术] by (71.8m points)

uikit - Using constraints on detached view

I am writing an invoice generator that loads a view from a .xib file, then finds and populates its labels with some values, and finally renders the view into a PDFDocument.

This works fine, but it requires that the template view be temporarily attached to the view hierarchy or its constraints don't work. After rendering, the template view is detached, and the app show the finished PDF document inside a PDFView.

My question is: Is it possible to use constraints on a detached view? I would like to avoid passing a superview to the generator, and having it add and remove the template from its subviews. The template's constraints reference only its own views and safe area margins, not superviews, so it seems that it shouldn't need to be in a view hierarchy. I tried setting the template view's frame explicitly, calling updateConstraints, and layoutSubviews, but none of these had any effect.

question from:https://stackoverflow.com/questions/65850964/using-constraints-on-detached-view

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...