I just want to turn the auto layout feature for one view only in mystoryboard . is that possible and if yes , how do I do that . I'm using xcode 4.6.3
-
1No, you can't do that. It is a storyboard or xib wide setting. If you need it off for one view, make that view in a separate xib. – rdelmar Dec 07 '13 at 23:34
-
in my programme I can't use xib files . So there is no other solution ? – user2988343 Dec 07 '13 at 23:43
-
1No, There is no way to disable for a single VC. Use xib, or do without autolayout entirely. – CaptJak Dec 07 '13 at 23:50
-
Why do you need to turn of auto layout for that one view? – rdelmar Dec 08 '13 at 01:03
-
because I want to be able to change the position of the labels and print numbers in by code for each segment selection . It didn't work until I disabled the auto layout – user2988343 Dec 08 '13 at 01:09
-
the problem is that I have more than 20 views and i did them all using the auto layout so it will take ages to rearrange the objects in those views . – user2988343 Dec 08 '13 at 01:10
-
@CaptJak is right, it can't be done just for one view. the only way would be to manually construct the constrains. sorry pal.:( – Adrian P Dec 08 '13 at 04:36
-
maybe you don't need to turn off autolayout. what are you doing in order to change the position of the labels? – Marko Hlebar Dec 08 '13 at 10:28
-
im changing it by code for each condition using the centre propery of the label where I enter the points . – user2988343 Dec 08 '13 at 12:58
3 Answers
From the answer given by MuhammadAamirAli here, its possible. Here is a snapshot code from his answer, which I found useful.
[self.benchmarkButton removeFromSuperview];
[self.benchmarkButton setTranslatesAutoresizingMaskIntoConstraints:YES];
[self.benchmarkButton setFrame:CGRectMake(20, self.benchmarkButton.frame.origin.y+40, 260, 30)];
[self.benchmarksView addSubview:self.benchmarkButton];

- 1
- 1

- 661
- 11
- 19
This is not tested yet, but it could work and override the auto-layout done in interface builder, it also lets you specify a views array: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/AutoLayoutinCode/AutoLayoutinCode.html

- 740
- 6
- 17
Technically, everyone is right about not being able to turn off Auto Layout for individual scenes in storyboard. However, even if the global "switch" for Auto Layout is turned on in storyboard, you can still use autoresizing masks (i.e., the springs-and-struts system) anywhere you want. Although the system will convert the masks into "auto-resizing" constraints behind the scenes, you won't have to deal with the constraints directly.
Just make sure that when you alloc/init a view programmatically, you set its translatesAutoresizingMaskIntoConstraints property to YES.

- 8,918
- 6
- 36
- 50