Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
640 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...