Questions tagged [autolayout]

Auto Layout is a constraint-based, descriptive user interface layout system for OS X and iOS.

The Auto Layout system defines layout constraints for user interface elements. Constraints represent relationships between user interface elements such as “these views line up head to tail,” or “this button should move with this split view subview.” When laying out the user interface, a constraint satisfaction system arranges the elements in a way that most closely meets the constraints. Constraints are objects and can be established in storyboards and XIBs, exposed as outlets, and created or modified in code.

11052 questions
29 answers

Using Auto Layout in UITableView for dynamic cell layouts & variable row heights

How do you use Auto Layout within UITableViewCells in a table view to let each cell's content and subviews determine the row height (itself/automatically), while maintaining smooth scrolling performance?
  • 30,197
  • 11
  • 60
  • 73
12 answers

How do I animate constraint changes?

I'm updating an old app with an AdBannerView and when there is no ad, it slides off screen. When there is an ad it slides on the screen. Basic stuff. Old style, I set the frame in an animation block. New style, I have a IBOutlet to the auto-layout…
  • 23,075
  • 12
  • 60
  • 84
10 answers

Cocoa Autolayout: content hugging vs content compression resistance priority

I can't find a clear answer on Apple documentation regarding Cocoa Autolayout about the difference between content hugging and compression resistance. Can somebody explain their usages and difference ?
  • 8,994
  • 4
  • 30
  • 45
34 answers

UIScrollView Scrollable Content Size Ambiguity

Fellow devs, I am having trouble with AutoLayout in Interface Builder (Xcode 5 / iOS 7). It's very basic and important so I think everyone should know how this properly works. If this is a bug in Xcode, it is a critical one! So, whenever I have a…
  • 6,713
  • 3
  • 15
  • 13
19 answers

How to add constraints programmatically using Swift

I'm trying to figure this out since last week without going any step further. Ok, so I need to apply some constraints programmatically in Swift to a UIView using this code: var new_view:UIView! = UIView(frame: CGRectMake(0, 0, 100,…
Sara Canducci
  • 6,231
  • 5
  • 19
  • 24
41 answers

How do I size a UITextView to its content?

Is there a good way to adjust the size of a UITextView to conform to its content? Say for instance I have a UITextView that contains one line of text: "Hello world" I then add another line of text: "Goodbye world" Is there a good way in Cocoa…
  • 10,077
  • 7
  • 34
  • 43
4 answers

How to get StackPanel's children to fill maximum space downward?

I simply want flowing text on the left, and a help box on the right. The help box should extend all the way to the bottom. If you take out the outer StackPanel below it works great. But for reasons of layout (I'm inserting UserControls dynamically)…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
24 answers

How to use Auto Layout to move other views when a view is hidden?

I have designed my custom Cell in IB, subclassed it and connected my outlets to my custom class. I have three subviews in cell content which are: UIView (cdView) and two labels (titleLabel and emailLabel). Depending on data available for each row,…
  • 4,337
  • 5
  • 18
  • 25
8 answers

Emulating aspect-fit behaviour using AutoLayout constraints in Xcode 6

I want to use AutoLayout to size and layout a view in a manner that is reminiscent of UIImageView's aspect-fit content mode. I have a subview inside a container view in Interface Builder. The subview has some inherent aspect ratio which I wish to…
  • 5,148
  • 6
  • 23
  • 27
10 answers

Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0

I opened an existing iOS project with Xcode6 beta6, and Xcode lists the following warning for both Storyboard and Xib files: Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0 I tried addressing the warning by…
  • 4,340
  • 3
  • 21
  • 49
21 answers

Getting a "This application is modifying the autolayout engine from a background thread" error?

Been encountering this error a lot in my OS X using swift: "This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release." I…
  • 12,359
  • 5
  • 21
  • 37
23 answers

What is NSLayoutConstraint "UIView-Encapsulated-Layout-Height" and how should I go about forcing it to recalculate cleanly?

I have a UITableView running under iOS 8 and I'm using automatic cell heights from constraints in a storyboard. One of my cells contains a single UITextView and I need it to contract and expand based on user input - tap to shrink/expand the…
  • 17,070
  • 9
  • 50
  • 73
6 answers

How to trap on UIViewAlertForUnsatisfiableConstraints?

I'm seeing an error appear in my debugger log: Will attempt to recover by breaking constraint Make a symbolic breakpoint at…
Maury Markowitz
  • 9,082
  • 11
  • 46
  • 98
8 answers

When is layoutSubviews called?

I have a custom view that's not getting layoutSubview messages during animation. I have a view that fills the screen. It has a custom subview at the bottom of the screen that correctly resizes in Interface Builder if I change the height of the nav…
Steve Weller
  • 4,599
  • 4
  • 23
  • 30
29 answers

Evenly space multiple views within a container view

Auto Layout is making my life difficult. In theory, it was going to be really useful when I switched, but I seem to fight it all of the time. I've made a demo project to try to find help. Does anyone know how to make the spaces between views…
  • 3,097
  • 4
  • 16
  • 15
2 3
99 100