Questions tagged [autolayout]

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

0
votes
1answer
44 views

How can I make a multi-line label the correct height when its font adjusts to fit the available width?

I have designed a view containing two labels. The title text is variable and it should look good for short and long titles, so it is set up to support multiple lines of text (numberOfLines is 0) until ...
0
votes
0answers
15 views

xcode I want my app to be located in the middle in any devices

I am making app for IPhone. When it is opened at Ipad, it is appeared as figure 1. But I want to modify this as figure 2. I have tried to use set center vertically and horizontally in Container, ...
0
votes
0answers
29 views

viewDidLayoutSubviews getting called twice and convertPoint improperly converting on first render

I am trying to animate UITabBar items by using a UIImageView and setting its frame in the same frame as my UITabBarItem's when the view first renders to the user. In a different project, it works fine ...
0
votes
1answer
27 views

Adding view beneath navigation bar in navigation controller

I'm trying to add a UIView beneath the UINavigationBar in my UINavigationController. The view will serve as a placeholder for information messages (for example if we are having issues and content is ...
0
votes
1answer
36 views

Dynamic sized UIImageView in UIScrollView with some complex conditions

How should I configure AutoLayouts if I want to create this kind of layout? Or let me know if it's impossible by only AutoLayout. [UIView] [UIScrollView] [UIImageView] [UILabel] [...
1
vote
2answers
76 views

How I can create this circular shape in iOS Swift4?

I have to create this shape like the below image in a UIView. But I am not get any idea how to draw this shape. I am trying to draw this shape using UIBezierPath path with CAShapeLayer the circular ...
0
votes
0answers
27 views

UICollectionViewFlowLayout estimatedItemSize breaks constraints during rotation but itemSize is totally fine

I'd like to display a bunch of UICollection view cells with images and labels and adjust their widths according to width of the labels. I don't want to override sizeThatFits() neither to override ...
0
votes
1answer
52 views

Prevent UIStackView from compressing UITableView

I am adding a UITableView into vertical UIStackView. That vertical UIStackView is within a UIScrollView. However the table is not displaying unless I force an explicit Height constraint on it which ...
0
votes
2answers
41 views

How do I make a UITableViewCell resize when a UITextView size changes?

I'm having an Auto Layout with SnapKit issue. I added a UITextView to a UITableViewCell, and I want the cell to expand as the text view expands when the user adds content. However, in reality, when ...
3
votes
0answers
54 views

TableView frame change - wrong cell layout?

Changing the tableView's height (constraint) results invalid cell layout. In this case the keyboard appearing - disappearing changes the height. Video of the bug: https://youtu.be/DOpyKzOUzdg I don'...
0
votes
3answers
36 views

Safely change NSLayoutConstraint constant value

I have bottom constraint of my UIView object, and i want to change it value. After i did, view did display correctly, but, i see an error log in console; [LayoutConstraints] Unable to simultaneously ...
0
votes
1answer
24 views

Set height of image subview in vertical stack view

I have a UITableViewCell that contains content in a stacked pattern. Header (UILabel) Sub Header (UILabel) Image (UIImageView) Content Body (UILabel) The image is not a fixed height, I download from ...
-1
votes
2answers
53 views

Constraints not getting updated when changing bounds origin of UIView

I have an UIView A which contains another UIView B (subview of A). There is another UIView C (subview of the parent of UIView A) and it has constraints applied such that the top anchor of UIView C is ...
2
votes
2answers
38 views

UIStackView - Positioning Image up against edge of sibling

I am trying to create a custom UITableViewCell in iOS that contains a Label and a related image. The image needs to be as close the the trailing edge of the label as possible. Below is an image of ...
1
vote
1answer
127 views

Added subview is positioned slightly off - how can I get it back into place?

UPDATE: Solved! While the contentMode for pianoNoteDisplayed and piano_background were indeed the same, apparently this wasn't true for the added subviews. I simply added the line subview.contentMode =...
-4
votes
1answer
33 views

Why is it asking me for a Y position or a height? How can I fix it?

This is a very basic question and I am just not being able to fix it. I am just trying to have two equal sized views on my scene. And I've set the constraints on both and having the: vertical ...
-1
votes
1answer
21 views

Stack View Wrap Elements

My overall container is a vertical stack view. Inside of it, I want to have two Buttons with dynamically generated content. For larger devices where both button text's fit inside the screen ...
0
votes
1answer
17 views

ScrollView with StackView and fixed footer outside

Xcode 10, Swift 5 (this should be doable purely in the Storyboard) The current layout: - ChildView (child View of very first default view) - ButtonView - ScrollView - ...
0
votes
2answers
46 views

Autolayout and storyboard not working - Swift?

I am new to swift and ios development and I have been following this tutorial: https://www.youtube.com/watch?v=Vq71SPkJIus But for some reason even though I have the text in the feature view with ...
0
votes
1answer
19 views

Why does the UIScrollView calculate a massive contentSize with AutoLayout?

So I've followed all the best practices with respect to having a scrollable content view that works with autolayout (first have one direct subview of UIScrollView, add all the pin constraints, etc), ...
2
votes
4answers
99 views

How to deal with safe area when using Size Classes?

I just created a simple red view and create 4 constraints for it (top, left, right, bottom). I am trying to make adaptive layout using size classes, but cannot achieve correct layout in "landscape ...
-1
votes
2answers
31 views

popoverController does not show after upgrading Xcode from 7 to 10

I have this app that was previously developed and maintained at Xcode 7. But recently we had to upgrade Xcode to 10 to be able to post the app to apple store. Many layout were broken upon the update ...
0
votes
1answer
35 views

iOS custom UIView has different layout in iphone xr and iphone 7

I got auto-layout issue with custom UIView which render correctly in iphone XR as but wrong in iphone 7s(the "Reset" button is rendered out of bound) and setting in storyboard with just a ...
2
votes
2answers
39 views

Swift text field border isn't the right width

I have a bottom border that I generated after following the answer here. This works absolutely great except the border isn't the right width. It's set with constraints to match the width of the ...
0
votes
0answers
27 views

Why does Auto Layout break down when bringing app from background to foreground?

I'm working an iOS movie app which has a home screen and a "Select Genres" screen. When tapping a button on the home screen (https://i.imgur.com/hiBZM82.png), it sends the user to the Select Genres ...
0
votes
0answers
16 views

IQKeyboardManager on Iphone XR with autolayout--Weird error every third time you tap on textView

I am using IQKeyboard manager in a project and it generally works great. When you tap on a textview, as the keyboard appears, the textview move up 10 points above the keyboard so you can see what you ...
-4
votes
1answer
38 views

How to support multiple screen sizes for iPhone in Xcode?

How can we support multiple screen sizes in Xcode iOS for iPhone? Why isn't it any kind of guide for this?
0
votes
0answers
15 views

Autolayout constraint conditional

I have a view and I add a subview to this with the following Autolayout requirements: If view width is greater than or equal to view height, then i want subview width to be 75% of view width and ...
0
votes
1answer
26 views

Xcode storyboard: How to fit different screen sizes with 10+ textfields

I've been working with a layout for now in pretty much +2 days. Watching multiple youtube videos, reading pretty much 50+ stack overflow threads, but I can't get my layout to fit different screen ...
1
vote
2answers
36 views

iOS: UILabel is not centered while expanding view with UIViewControllerTransitioningDelegate

I am trying to present modally a view when tapping a button, that would have at first the same frame than the button, and then expanding to end up full screen, all this using ...
0
votes
2answers
83 views

Swift: loading image asynchronously in UITableViewCell - Autolayout issue

In my UITableViewCell I have a UIImageView that download image asynchronously (with Kingfisher library). It's very similar to Instagram. I'm using autolayout and I want to use UITableView....
0
votes
1answer
50 views

Setting UITableViewCell height programmatically with Auto Layout

I want to set my cell height with auto layout, here is the code: class AccountsBalanceResidueCell : BaseCell { private let title: UILabel = { let lbl = LabelSL.italicLarge() lbl....
0
votes
2answers
37 views

Autosizing superview height according to tallest subview button

I have following layout. The yellow view is a buttonsContainerView which acts as a container for 3 equal width buttons that it holds. All the three buttons are subview of yellow coloured ...
1
vote
1answer
33 views

iOS: Problem with horizontal centers alignment and layout

I want the below Yes and No buttons to be at bottom center of the screen side-by-side, always with same width. The other labels are behaving as expected. Problem is with the buttons. They just appear ...
0
votes
1answer
52 views

Autolayout conflict when hiding subview of UIStackview

When hiding subviews of UIStackview in tableviewcell, sometimes autolayout conflicts occured. I tried also addArrangedSubview and removeArrangedSubview instead of hiding and unhiding. But it was same ...
0
votes
1answer
42 views

Hide an element and take up its space in Swift (iOS)

I'm new into iOS development and one of the most difficult things for me is all the Auto Layout stuff. I'm trying to create a simple app that displays a message saying that the iOS version the user is ...
0
votes
1answer
46 views

How can a stackview dynamically change the spacing between the elements nested inside of it

For months now I have been trying to wrap my head around stackviews and how they work. For that reason I have created a project which has 4 buttons nested inside of a stack view with constant width ...
0
votes
1answer
23 views

Adjust UITableView to allow for keyboard

What is the magical incantation for adjusting a UITableView's height when the keyboard is shown on-screen FOR ALL DEVICES? In the keyboardDidShow notification, I'm doing tableView.contentInset = ...
0
votes
0answers
27 views

Why is UIViewPropertyAnimator crashing with autolayout, but not when using frames?

Im sure this is a simple fix, but for the life of me i cant see it, so i apologise in advance! I am animating a small card from the bottom of the screen, to an enlarged state that takes up nearly all ...
0
votes
1answer
29 views

Why do these constraints seem to lag when animated?

I am animating my constraints using UIView.animate. drawerHeight is a constraint variable. Here is the code: drawerHeight?.constant = newHeight UIView.animate(withDuration: 0.35, delay: 0, ...
0
votes
1answer
25 views

Prevent sizeForItemAt from using the wrong cell size because of reuse for dynamic collectionView cell

I used auto layout to dynamically calculate the size of the collectionView cell. Some cells are using the dimensions from the reused cells when they first scrolled to view port. As I continue to ...
1
vote
0answers
27 views

Determine value for default layoutMargins

The system changes the layoutMargins of the main view, according to size classes like for small iPhones it's left value is 16, for the X phones it's 20 Besides asking the view controllers for it's ...
0
votes
1answer
57 views

Animate constraints change UIViewController

I have "error" view, that is placed above navigation bar and hidden. When error occured, i want that view to smoothly show from top. I tried: class AuthViewController: UIViewController { let error:...
0
votes
2answers
42 views

Resize cell after scrolling (Autolayout)

Resize cell size after some scrolling. CommentViewController.swift Code override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. tblView....
0
votes
1answer
52 views

Updating AutoLayout Constraints When UIView Height Changes

I currently have a UIView (we'll call this viewB) added to a parent UIScrollView, which we'll call scrollView. This functions as expected, with viewB being added like so; viewB.topAnchor.constraint(...
0
votes
2answers
47 views

How do you auto layout constraint a notification label inside a button?

This is the screenshot of my issue. My problem is the button label is not a view. I can not anchor that notification label to it. If I anchor that label to any of the sides, the screen size will ...
0
votes
2answers
30 views

Understanding UIView Height When Constraints Are Set with AutoLayout/UIScrollView

I hope this helps, but I am trying to wrap my head around a concept. I have a UIScrollView, added to a self.view in my ViewController, with its top, leading, trailing, and bottom edges pinned to ...
2
votes
0answers
25 views

Animating constraints with layer-backed NSView

I'm attempting to implement an animation that shows/hides a view in a horizontal arrangement. I'd like this to happen with slide, and with no opacity changes. I'm using auto-layout everywhere. ...
0
votes
1answer
47 views

Programmatically set constraint priority

I have a requirement to recreate a .xib based layout programmatically. I have largely been able to achieve this, however, cannot set the priority of one of my anchors. The setting I am trying to ...
0
votes
0answers
25 views

Swift: How to make UITableView with dynamic cell sizes appear in UIStackView?

I am trying to place a UITableView with self-sizing cells in a UIStackView. The UITableView's isScrollEnabled property is set to false. The UITableView is then added to a UIView, this UIView is added ...