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
4
votes
2 answers

AutoLayout: UIImageView and Aspect Fit content mode

I'm trying to place an UIImageView in the parent view's center. Image must keep its original aspect ratio and also it shouldn't exceed parent's bounds. So landscape images should be limited by parent's width and portrait images should occupy as much…
fraggjkee
  • 3,524
  • 2
  • 32
  • 38
4
votes
1 answer

Setting UICollectionViewCellSize at runtime

I have a stack view that contains three UICollectionViews, set up to give each of them equal vertical space. That stack view is set to be the height of half of the display, so that it uses more space on larger devices. This has been set up in…
4
votes
2 answers

AutoLayout : Relative scaling of views

I want to achieve consistent views across different screens. My layout constraints works on small screens perfectly but it scrambles on large screens. I have made a view(Red Border indicating that view)and pin it in to the main super view. Then I…
osama
  • 1,286
  • 18
  • 22
4
votes
2 answers

Custom TableViewCell triggers NSLayoutConstraint error 'UIView-Encapsulated-Layout-Height'

I use Automatic Height for cells. And each time I want to update my cell with new data (model variable here) I updated my autolayout constraints and I get an error. Here just to show the issue, I don't even change the constraints. I simply ask to…
Mikael
  • 2,355
  • 1
  • 21
  • 45
4
votes
3 answers

Autolayout constraints to set labels horizontally

I have a bar with two UILabels: [LeftMsg RightMsg] The rules I want to set are: RightMsg is always fully visible, right-aligned and takes the room it needs. LeftMsg is left-aligned and takes the remaining room. For…
Nick
  • 3,205
  • 9
  • 57
  • 108
4
votes
2 answers

Easiest way to Adjust UIButton Size based on Text

I have text which can be of variable length. I want to adjust the size of the button to show the text. Some times the text is too much and in those cases I want to limit the size to certain width. How can I do that for UIButton. Above is the text…
john doe
  • 9,220
  • 23
  • 91
  • 167
4
votes
1 answer

Why is my UISearchBar's width 0 after becoming first responder?

I have a UISearchBar in my UIStackView with a button, making a sort of nav bar. Here is what it normally looks like: but when it becomes first responder the UISearchBar's width goes to 0, and it looks like this: Now the only constraint I have is the…
A Tyshka
  • 3,830
  • 7
  • 24
  • 46
4
votes
0 answers

No runtime warning when content compression/hugging constraints conflict with specific width/height constraints

Example A UIButton that has: 1000 priority width constraint (say width = 20) 1000 priority horizontal compression resistance priority wide content that is bigger than 20 I don't get any runtime warning (the one in debugger), but for me it seems…
4
votes
0 answers

What's the difference between flexibleMaxX,flexibleMaxY and widthSizable,heightSizable in Xcode IB editor?

I have 2 UIViews in Xcode storyboard/xib editor. The good view is created when I create a XIB file from File > New. The bad view is the one I dragged from the drawer. I'm not able to tell the difference in the attributes, size, identity inspectors…
sonoluminescence
  • 1,002
  • 1
  • 11
  • 28
4
votes
2 answers

How to make floating view?

What I mean by floating view is custom view that is a subview (or appears to be a subview) of scrollview which scrolls along until it anchors on certain point. Similar behavior would be UITableView's section header. Attached image below My content…
Dickson Leonard
  • 518
  • 5
  • 14
4
votes
5 answers

Set Dynamic Cell's Table View Content height to table view height constraints ios

I have tableview(A)'s every custom cell having tableview(B) with dynamic table view cell. At tableview(A) cellForRowAtIndex. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ …
Ravi Kumar
  • 1,356
  • 14
  • 22
4
votes
2 answers

set image height in aspect fill in auto layout in Xcode

how to set the images in aspect fill when using the auto layout. When i design in storyboard it's perfectly fine but when setting the image, the height of image view goes very high. i want it to be a constant , i've also added the constant for that…
Arun kumar
  • 55
  • 1
  • 9
4
votes
0 answers

intrinsicContentSize causes infinite loop in special case

I made a container view i call SimpleStackView. The idea is simple, any subviews are stacked on top of eachother. The width of a SimpleStackView determines the width of its subviews, and the height of a SimpleStackView is determined by the height of…
quad16
  • 184
  • 5
  • 20
4
votes
3 answers

Resize container UIView to match height of visible subview after hiding mutually exclusive subview

ParentView contains ChildView1 and ChildView2. These subviews are of different heights. ChildView1 is taller than ChildView2. Only one subview is shown, e.g., if ChildView1 is visible then ChildView2 is hidden. Both ChildView1 and ChildView2 use…
Crashalot
  • 33,605
  • 61
  • 269
  • 439
4
votes
6 answers

Content in scroll view is shifted down with height value of navigation menu

I use view controller with embedded in navigation controller. In this view I added scroll view and then content view inside scroll view I added constrains for scroll view - zero for top, bottom, leading, and trailing. And the same for content view -…
Bogdan Laukhin
  • 1,454
  • 2
  • 17
  • 26