ios - Automatically set UIView vertical size based on device vertical size (including Auto Layout changes) -
i've been googling on , can't seem pinpoint answer question have.
i'm writing app , vertical space of child uiview maintain height of device or rotation of parent device regardless of orientation , without hardcoding values ahead of time.
the structure of layout is:
viewcontainer uiview uiscrollview uiview (content view)
specifically, have vertical space of content view set native height of device/orientation running on, , when device rotates, vertical space change new vertical height. uiscrollview used pan horizontally only.
i using quartz draw in view. set initial height via intrinsiccontentsize
? if how query parent view?
i've tried using self.superview
within content view doesn't work. how detect change has occurred, , after occurs, how new y resolution , apply it? not want disable auto layout if don't have to.
here visual of want if haven't made clear: https://www.evernote.com/l/aai3vfkkbarplypsourjowamiigielf5p-w
i have app same view hierarchy.
what want achievable pure autolayout, following constraints. vertical constraints included here:
view.addconstraints(nslayoutconstraint.constraintswithvisualformat("v:|[scrollview]|", options: .allzeros, metrics: nil, views: ["scrollview" : scrollview])) scrollview.addconstraint(nslayoutconstraint(item: contentview, attribute: .height, relatedby: .equal, toitem: scrollview, attribute: .height, multiplier: 1.0, constant: 0.0)) scrollview.addconstraints(nslayoutconstraint.constraintswithvisualformat("v:|[contentview]|", options: .allzeros, metrics: nil, views: ["contentview" : contentview]))
since height of contentview correct, not sure whether still want notified of orientation changes.
Comments
Post a Comment