ios - Resizing and placing a rotated view in landscape: updating constraints or translating/changing frames? -


i've subview have placed @ bottom of screen in portrait orientation:

enter image description here

i've set constraints in storyboard orientation pin leading, trailing, , bottom space superview, fixed height of subview.

i want subview @ right side of screen when device in landscape orientation this:

enter image description here

in uiviewcontroller subclass behind, apply m_pi/2 radians rotation subview in viewwilltransitiontosize:withtransitioncoordinator:, result:

enter image description here

i tried place subview right side of screen want, after rotation call [self.view setneedsupdateconstraints]; , tried set new constraints orientation, i'm not able result want. so, i'm not sure if i'm trying wrong thing... thought setting new constraints pin subview right side of screen, resize height , refresh x , y values... or maybe right way translate rotated subview , change frame?

how solve this?

thanks

edit: example of constraints i'm programmatically setting landscape:

nslayoutconstraint *customsubviewconstrainttop = [nslayoutconstraint constraintwithitem:self.customsubview          attribute:nslayoutattributeleading          relatedby:nslayoutrelationequal          toitem:self.view          attribute:nslayoutattributeleading          multiplier:1.0          constant:0]; 

this supposed pin top of subview (left side before being rotated) top of screen (right side of screen when in portrait)... right?

edit 2: code have landscape constraints in updateviewconstraints:

if (!isportrait) {      self.customsubview.transform = cgaffinetransformrotate(cgaffinetransformidentity, m_pi/2);      [self.view removeconstraint:self.customsubviewconstraintl];     [self.view removeconstraint:self.customsubviewconstraintr];     [self.view removeconstraint:self.customsubviewconstraintb];     [self.view removeconstraint:self.customsubviewconstrainth];      [self.customsubview settranslatesautoresizingmaskintoconstraints:no];      self.customsubviewconstrainth = [nslayoutconstraint constraintwithitem:self.customsubview                                                           attribute:nslayoutattributewidth                                                           relatedby:nslayoutrelationequal                                                              toitem:nil                                                           attribute:nslayoutattributenotanattribute                                                          multiplier:1.0                                                            constant:35.0];      self.customsubviewconstraintl = [nslayoutconstraint constraintwithitem:self.customsubview                                                           attribute:nslayoutattributeleading                                                           relatedby:nslayoutrelationequal                                                              toitem:self.view                                                           attribute:nslayoutattributeleading                                                          multiplier:1.0                                                            constant:0.0];      self.customsubviewconstraintr = [nslayoutconstraint constraintwithitem:self.customsubview                                                           attribute:nslayoutattributetrailing                                                           relatedby:nslayoutrelationequal                                                              toitem:self.view                                                           attribute:nslayoutattributetrailing                                                          multiplier:1.0                                                            constant:0.0];      self.customsubviewconstraintb = [nslayoutconstraint constraintwithitem:self.customsubview                                                           attribute:nslayoutattributebottom                                                           relatedby:nslayoutrelationequal                                                              toitem:self.view                                                           attribute:nslayoutattributebottom                                                          multiplier:1.0                                                            constant:0.0];      [self.view addconstraint:self.customsubviewconstrainth];     [self.view addconstraint:self.customsubviewconstraintl];     [self.view addconstraint:self.customsubviewconstraintr];     [self.view addconstraint:self.customsubviewconstraintb]; } 

you use screen-bounded constrains, such bottomlayoutguide. use vertical spacing instead.

upd: problem set rotation custom view in viewwilltransitiontosize:withtransitioncoordinator:. set desired height , width instead.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -