Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opting out of auto layout for a single view?

Tags:

ios

autolayout

I have a view that performs layout of its subviews in code. The layout is too complex for auto layout, and auto layout breaks the layout code. Is there any way to force auto layout to leave this view's subviews alone? I've tried overriding layoutSubviews, but no joy.

Thanks for any help.

like image 845
Dan Wesnor Avatar asked Oct 08 '12 20:10

Dan Wesnor


People also ask

What do you mean by auto layout?

Auto Layout is a constraint-based layout system designed for building dynamically sized user interfaces. It lets you create user interface layouts that dynamically adapt for all screen sizes without manually setting the frame of every view.

What are the different types of auto layout?

There are three main types of Auto Layout issues: ambiguous layouts, unsatisfiable constraints and logic errors.

What is a layout in AutoCAD?

Display one or more scaled views of your design on a standard-size drawing sheet called a layout. After you finish creating a model at full size, you can switch to a paper space layout to create scaled views of the model, and to add notes, labels, and dimensions.

How to create multiple layout viewports in paper space in AutoCAD?

Note: You can use the MVIEW (make view) command to create additional layout viewports in paper space. With several layout viewports, you can display several views of model space at the same or at different scales. Here are the steps to follow if you use the trans-spatial method of annotating your drawing:

What is layout viewport in AutoCAD?

A layout viewport is an object that is created in paper space to display a scaled view of model space. You can think of it as a closed-circuit TV monitor that displays part of model space. In the illustration, model space is active and accessible from within the current layout viewport.

How do I set the layout of an individual view?

Razor views have a Layout property. Individual views specify a layout by setting this property: The layout specified can use a full path (for example, /Pages/Shared/_Layout.cshtml or /Views/Shared/_Layout.cshtml) or a partial name (example: _Layout ).


2 Answers

Auto-layout is enabled or disabled per storyboard or XIB. If your view is in its own XIB, then you can disable auto-layout for that XIB. If there are other views in your XIB that rely on auto-layout, you'll have to find a different solution.

like image 187
Scott Berrevoets Avatar answered Sep 19 '22 15:09

Scott Berrevoets


Found the answer in the WWDC videos. layoutSubviews does not work the same under auto layout as it did before. It does not stop auto layout from happening, but rather is an opportunity to add/change/remove constraints during layout.

Last night I tried moving the custom view to a different NIB and that seems to be the only solution.

like image 34
Dan Wesnor Avatar answered Sep 18 '22 15:09

Dan Wesnor