Questions tagged [ios-autolayout]

In iOS, Auto Layout dynamically calculates the size and position of all the views in your view hierarchy, based on constraints placed on those views.

In iOS, Auto Layout dynamically calculates the size and position of all the views in your view hierarchy, based on constraints placed on those views.

More info

1049 questions
7
votes
0 answers

Smoothing resizing animations of content compression resistance priority/size constraints on auto layout

I have a view with ≤ constant height constraint and a fixed width constraint. Inside it, I have a text view with leading/trailing/top/bottom constraints to that outer view, effectively being "docked" inside that view (just with a few point margins).…
Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389
6
votes
3 answers

Unable to activate because they have no common ancestor IBOutlet and code

I am trying to add a constraint to a tableview I created and added to view programatically. I want to constraint it based on a UITextField which is an IBOutlet. However, I am getting the following error: *** Terminating app due to uncaught…
John Doe
  • 2,225
  • 6
  • 16
  • 44
6
votes
2 answers

modalPresentationStyle formSheet issues on iphone XR, XS Max

I am displaying modal UIViewController with modalPresentationStyle = .formSheet but it has some issues on iphone XR and XS Max. It's displayed behind notch. Image bellow from left side iphone XR, XS, X. UIViewController use autolayout and is…
Martin Vandzura
  • 3,047
  • 1
  • 31
  • 63
6
votes
0 answers

Why do we need invalidateLayout?

i tried to implement rotation adjustments so in tutorial author was using invalidatelayout function before setting new preferences. but all actually works without invalidateLayout, and yet i tried it in another circumstance before and got the same…
Ninja
  • 309
  • 7
  • 26
6
votes
1 answer

Xcode 9.1 Warns "Language directional layout margins before iOS 11.0"

I noticed an Xcode warning that said : "Language directional layout margins before iOS 11.0" Even this question left unanswered in Apple developer forum thead. I have used storyboard & warning doesn't lead to any specific view. What is the cause…
byJeevan
  • 3,728
  • 3
  • 37
  • 60
6
votes
1 answer

Relative positioning using auto layout and SnapKit

I have a label which I want to have the same relative position on the screen, no matter what device is used. E.g. the label is positioned 10% off from the views top margin and 30% off from the views left margin. A constant will always do the…
Jake2Finn
  • 516
  • 5
  • 19
6
votes
1 answer

How to programmatically add an InputAccessoryView with Autolayout?

I am trying to add a UIView with "Done" button as an input accessory view to the text field. let view = UIView() let doneButton = UIButton(type: .Custom) doneButton.setTitle("Done", forState: .Normal) …
user5381191
  • 611
  • 7
  • 21
6
votes
2 answers

Custom UITableViewCell with auto layout and accessory view

I have a custom table view cell that uses auto layout and has a disclosure indicator as an accessory view. The cell size of the cells on the screen are completely wrong when first displayed: As you can see the cell is taking about a 1.5 screens…
6
votes
3 answers

Stretch two buttons horizontally across all devices AutoLayout

I'm attempting to have two buttons side by side that look correct across all devices but no matter what constraints I seem to add in I keep getting issues similar to this (one button larger then the other): Any ideas what I'm doing wrong as far as…
James
  • 201
  • 4
  • 13
5
votes
2 answers

Custom interfaces for Portrait & Landscape mode iOS

I am trying to layout user interfaces differently for Portrait & Landscape orientations. The difference comes in the following ways: I have few UIStackViews. Some of their axis becomes horizontal in landscape but vertical in portrait mode, The…
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
5
votes
0 answers

Safe area insets wrong after changing window rootViewController

I am using inputAccessoryView of UIViewController. Everything works fine until I change UIWindows rootViewController. After that safeAreaInsets for portrait are reported as landscape and other way around. This is only happening when changing from…
josip04
  • 224
  • 3
  • 13
5
votes
2 answers

Need constraints for y position, height - Auto layout Storyboard

First let me tell that I have gone through multiple same kind of questions available in Stack Overflow but neither of them helped me. So I created new question for discussing my problem. I am beginner with iOS programming and with layout making in…
Siddharth
  • 4,142
  • 9
  • 44
  • 90
5
votes
3 answers

Is it necessary to use autolayout to use stackview

Is it necessary to compulsory use autolayout to just use of stackview suppose i have made whole project without autolayout, now for particular screen i have to use the Stackview to equally divide the number of label inside the view. is there is any…
Jaydeep Vyas
  • 4,411
  • 1
  • 18
  • 44
5
votes
1 answer

How to change height Constraint of UIView in UitableviewCell when using UITableViewAutomaticDimension

I have a UIView in the UITableViewCell , which needs to change its height when user taps on "less/more" button My code is - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath { return…
5
votes
2 answers

Safe Area Guide Not Appearing in Xcode

I use XIB in most of my apps instead of Storyboards. As you can see from the picture, I have Safe Area Layout Guide enabled as well as Auto Layout, but for some reason, my XIB still shows top and bottom layout guide instead of safe area. What am I…
user717452
  • 33
  • 14
  • 73
  • 149