ios - Find the size of a UIView from its layout constraints -
i have xib file, shown below. need find out how tall going auto-layout constraints. text dynamic , wrapping. width of whole view can vary well.
when view's added view controller everything's in right place, i'm confident constraints set correctly, problem want synchronously instantiate view, tell set , ask it's total frame going be.
i've tried things along lines of
let view = myview.loadfromnib() view.putmytextonallthelabels() view.setneedsupdateconstraints() view.updateconstraintsifneeded() view.setneedslayout() view.layoutifneeded() let fixedwidth: cgfloat = 100 let size = cgsizemake(fixedwidth, cgfloat.max) let desiredframe = view.systemlayoutsizefittingsize(sizetoassesswith, withhorizontalfittingpriority: uilayoutprioritydefaultlow, verticalfittingpriority: uilayoutprioritydefaultlow) the desired frame never seems correct though. it's not same frame when view added view.
what useful, if there kind of callback or way of getting callback when of views , subviews subviews have decided on final frames, far can tell if call setneedsupdateconstraints or of lines follow in sample code, these don't seem apply constraints synchronously, if inspect position of labels straight after calling these methods in wrong places.
so how supposed find size auto-layout going make view?

Comments
Post a Comment