objective c - Strange NSLayoutConstraint Behavior -
i have uiscrollview add uitextview to. have following constraint adding view:
nslayoutconstraint *xconstraint = [nslayoutconstraint constraintwithitem:textview2 attribute:nslayoutattributeleading relatedby:nslayoutrelationequal toitem:_scrollview attribute:nslayoutattributeleading multiplier:1.0 constant:50]; this constraint works changing leading trailing so, has no effect. still displays based on leading.
nslayoutconstraint *xconstraint = [nslayoutconstraint constraintwithitem:textview2 attribute:nslayoutattributeleading relatedby:nslayoutrelationequal toitem:_scrollview attribute:nslayoutattributetrailing multiplier:1.0 constant:50]; i have no understanding why uitextview's location doesn't change position when change constraint leading trailing. realize need change 50 -50 if constraining trailing edge, isn't.
the solution turned out to insert uiview inside of uiscrollview. did in storyboard, , set top , bottom constraints uiview uiscrollview, set leading , trailing constraints uiview parent view contains uiscrollview in turn contains uiview. allows leading , trailing constraints function correctly.
Comments
Post a Comment