ios - Swift: Container View layout changes when rotating and rotating back again -


i working in xcode 7, using autolayout , targeting ios 9.3. have main view controller holds container view. container view holds child view controller.

the container view has leading , trailing constraint of -20 covers main view controller in horizontal.

when main view controller loads first time, however, content child view controller displayed inside container cut off on left , right (almost if not recognize constraint of -20 on left , right).

when rotate device landscape , again original portrait orientation child view controller scales correctly , no longer cut off on left , right.

so looks layout method being called when rotating device sideways , rotating again not called when view first loaded. method be? there way can manually call method force update on layout/size when child first loaded looks same after rotation , backwards rotation?

i found solution problem:

instead of setting leading , trailing constraint of -20 on container view, set constraint on container view same width main view , center horizontally in container.

with these constraints works on first load although cannot quite explain why behave differently original constraints. guess lesson autolayout if 1 way of sizing container behaves awkwardly under circumstances, try set of constraints achieve same result.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -