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
0 answers

How can I detect when display zoom is changed?

I can't find how can I detect in code when display zoom is changed from the device Settings: Because when the Display Zoom is Standard, all the AutoLayout works perfectly and when is Zoomedall the UIViews and UILabels overlaps each other and I…
pableiros
  • 14,932
  • 12
  • 99
  • 105
4
votes
0 answers

Supporting only iPhone when submitting to Apple

I submitted an update for my app in iTunes Connect which Apple rejected, giving the following reason: We noticed that your app did not run at iPhone resolution when reviewed on iPad running iOS 10.3. Specifically, the screen resolution was not…
Amalie
  • 282
  • 1
  • 3
  • 15
4
votes
1 answer

Get size of UILabel after setting text programmatically

When setting some string value to the text attribute of a UILabel like var a : UILabel a.text = "Variable length string" autolayout resizes it using the constraints font size, label number of lines etc. The question is, if I needed to get the size…
Return-1
  • 2,329
  • 3
  • 21
  • 56
4
votes
1 answer

Minimum scale factor for title of UIButton does not apply

This is my text in side of a UIButton: It should says "highscores", but it is okay now since it is in Storyboard and not running. My constrains are as followed: The proportional width is 0.3 of the superview. I settled this in my…
J. Doe
  • 12,159
  • 9
  • 60
  • 114
4
votes
5 answers

How to change UITableViewCell's height dynamically using Auto Layout?

A self-sizing UITableViewCell: MyTableViewCell.m -(void) viewDidLoad{ UIView *sample = [[UIView alloc] init]; [self.contentView addSubview: sample]; //Fake code here. Let sample view fill the whole contentView: …
LuRui
  • 111
  • 2
  • 4
4
votes
1 answer

Embedding Intrinsically Sized View Breaks Animation

I have built a test project to show what the goal is vs. what I currently have happening. The gif on the left shows exactly what I want the ending appearance to be. It is constructed with a single traditional view hierarchy. I need to achieve this…
Chris Trahey
  • 18,202
  • 1
  • 42
  • 55
4
votes
1 answer

Auto Layout on UIStackView with UIImageView inside - iOS Swift

I have some issues with auto layout when building view programmatically. There is a vertical UIStackView with several elements inside, mainly labels and images. After setting properties on stackView and imageView, as a result I get something similar…
Bastek
  • 899
  • 1
  • 12
  • 27
4
votes
1 answer

Trailing constraint not applying when programmatically adding UIConstraints

I'm trying to add a subview to a view with constraints through code. I had some success but the trailing constraint seems to be completely ignored for whatever reason. My code: leading_const = 16.f; trailing_const = 16.f; top_const =…
Kevin
  • 43
  • 3
4
votes
3 answers

Unknown class in Interface Builder file - Xcode 8 Swift 3

I ran into the following error Unknown class TutorialViewController.swift in Interface Builder file. when renaming the default files Main.storyboard and ViewController.swift to my desired naming convention of TutorialView.storyboard and…
Greg Hilston
  • 2,397
  • 2
  • 24
  • 35
4
votes
2 answers

getting NSLayoutConstraints associated view

I trying to loop through a views constraints. I added to view1: top, trailing, leading and height constraints. top, trailing and leading are to the main ViewControllers view. if i loop through view1's constraints i only see the height…
ilan
  • 4,402
  • 6
  • 40
  • 76
4
votes
4 answers

Xcode 8 : Auto layout Leading & Trailing

I started iOS development a week ago and I'm currently learning AutoLayout. and sadly I can't wrap my head around the Leading & Trailing constraints and when to use them, I don't even understand them at all. I have done some research and I'm just…
John
  • 141
  • 4
  • 12
4
votes
1 answer

Xcode adds duplicate constraints?

In code I added 4 constraints. But when I run the app, in UI debugger, it shows additional 6 constraints? It should be all clear with these 4 I added. I don't know what I'm doing wrong? let leftConstr = NSLayoutConstraint(item: image, attribute:…
4
votes
3 answers

Constraints for Centering One Button When the Other Is Hidden

I have two buttons on a view controller. They are equal in height and width and spaced nicely, centered on the screen. The problem is that in some circumstances, one of the buttons is hidden. When one of the buttons is hidden, I want the other…
4
votes
1 answer

Apply variations based on device's screen size in Xcode 8?

How do I apply auto layout variations based on the screen size of the selected device? All iPhone devices are Compact width Regular height, so if I want to add a variation for an iPhone 4s screen only, the variation gets applied to ALL iPhone…
Mark Carols
  • 403
  • 4
  • 20
4
votes
3 answers

Auto-layout margins with anchors

So, I thought the following was equivalent? # This is how I usually do contentView.leftAnchor.constraint(equalTo: leftAnchor, constant: 5).isActive = true contentView.topAnchor.constraint(equalTo: topAnchor, constant: 5).isActive =…
netdigger
  • 3,659
  • 3
  • 26
  • 49