objective c - AutoLayout fails, black background and autoresizing masks show up in any case -


i made uiview in storyboard containing 6 uibuttons.
wrote constraints support landscape mode portrait mode , put them in 2 different arrays: portraitmodeconstraints , landscapemodeconstraints. when mode changes, old constraints removed , right array gets added.

when load view in portrait mode there no problem. constraints work fine, wen turn ios-simulator, i'm getting lot of warnings. constraints work, tested them. constraints make problems ones autoresizingmask. turned them of on view controller using

[self.view settranslatesautoresizingmaskintoconstraints:no];

this made no change. debugged little bit , found out there no difference between settranslatesautoresizingmaskintoconstraints:no , settranslatesautoresizingmaskintoconstraints:yes strange , can't understand behaviour. however, deleted constraints manually this:

[self.view removeconstraints:self.view.constraints];

now, constraints worked in both portrait , landscape (the uibuttons @ right positions) background of uiview turned black , background image gone.

edit: when device rotate, function on viewcontroller called:

willanimaterotationtointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation duration:(nstimeinterval)duration;

in there check wether tointerfaceorientation landscape or portrait. when portrait, this:

[self.view removeconstraints:self.landscapemodeconstraints];
[self.view addconstraints:[nsarray arraywitharray:self.portraitmodeconstraints]];
[self.view layoutsubviews];

and when landscape this

[self.view removeconstraints:self.portraitmodeconstraints];
[self.view addconstraints:[nsarray arraywitharray:self.landscapemodeconstraints]];
[self.view layoutsubviews];

stack same problem, when controller embedded in nav controller, , i'm doing self.view.settranslatesautoresizingmaskintoconstraints(false) view black. there no reason set transl..... on self.view. need apply subviews. auto layout guide


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -