Can I disable autolayout for a specific subview at runtime? Can I disable autolayout for a specific subview at runtime? xcode xcode

Can I disable autolayout for a specific subview at runtime?


I had the same problem. But I have resolved it.
Yes, you can disable auto layout at runtime for a specific UIView, instead of disabling it for the whole xib or storyboard which is set by default in Xcode 4.3 and later.

Set translatesAutoresizingMaskIntoConstraints to YES, before you set the frame of your subview:

self.exampleView.translatesAutoresizingMaskIntoConstraints = YES;self.exampleView.frame = CGRectMake(20, 20, 50, 50);


I had a similar issue where Autolayout was overriding some of my frame-setting at run time (I had a dynamic view that in some cases pushed a new view controller...pushing and then pressing Back would reset the initial view).

I got around this by putting my manipulation code in viewDidLayoutSubviews of my View Controller. This seems to get called after whatever constraint mojo gets called, but before viewDidAppear, so the user is none the wiser.


Perhaps just setting translatesAutoresizingMaskIntoConstraints to YES (and not adding additional constraints affecting that view) will let you set the frame without fighting the auto layout system.