Questions tagged [autolayout]
Auto Layout is a constraint-based, descriptive user interface layout system for OS X and iOS.
12,009
questions
0
votes
1
answer
21
views
UIButton position to right side of UITextView in a growing textView
I have a UIButton() in a textView.
let expanButtonHeight = bounds.size.height
expanButton.frame = CGRect(x: textView.bounds.size.width - expanButtonHeight, y: 0, width: expanButtonHeight, height: ...
0
votes
1
answer
40
views
UIStackView change item spacing as stack view changes sizes
Overview
I have a stack view that has multiple circle views in it. The circle views could be images (like profile pictures) or anything. These views should be able to overlap if the size of the stack ...
0
votes
0
answers
41
views
Expand/Collapse UITableView always gets the wrong height
As this video, (you can download source code from here, I've tried my best to remove all the unnecessary code)
I need to manually scroll through tableview to make it reset to the right height of each ...
-1
votes
1
answer
46
views
IOS - How to remove NSAutoresizingMaskLayoutConstraint from a view
I am having issues getting rid of a pesky NSAutoresizingMaskLayoutConstraint that is breaking the auto-layout width constraints of some UITextView.
I have a UITableviewCell that contains a text view, ...
1
vote
0
answers
29
views
OTC View autolayout in SwiftUI
I'm new to swiftui and swift basically, i made One-time-code screen, and here i have a problem. When i run project on my old phone (iphone 6) when keyboard appears, my textfield size changes (it gets ...
0
votes
1
answer
23
views
How to update constraints programmatically if I would like to change every time
I have an imageView that is supposed to go up or down according to a value changing every time.
I am keeping a reference to the bottom constraint of imageView and changing this constant according to ...
0
votes
1
answer
34
views
Proportional sizing using equal heights missing constraint
I would like the blue container view to be the same height as the orange container view. I am using proportional sizing to do so (all of these are within a vertical stack)I selected all of the ...
0
votes
0
answers
20
views
Swift 5: How update the height of UIView depending if the tableview has new cells
I make a bottomSheet with a default heigh, I want to update when my tableview has one more cell, I would like to update it depending on the number of cells or the size of my tableview.
I have this but ...
1
vote
1
answer
34
views
Swift - Subviews frame.maxY reading incorrectly
I have a basic sign up screen set up programmatically with the UI elements inside a view that is itself inside a scroll view.
The last UI element in the screen is a register button. I set up a ...
3
votes
0
answers
61
views
iOS - CoreAutoLayout [NSISEngine withAutomaticOptimizationDisabled:] crash
I'm currently having production crashes reported by Firebase pointing to some auto-layout work being done on a background thread. While the fix would be obviously wrapping the offending code on a ...
0
votes
1
answer
47
views
Expand UICollectionViewCell to fit to width of a nested UICollectionView
I have a UICollectionViewCell that I want to expand when tapped. The cell is just a header that then expands into a smaller UICollectionView. The outer UICollectionViewCell is laid out via AutoLayout (...
0
votes
0
answers
27
views
AutoLayout doesn't work for custom UIView [duplicate]
I am trying to create a custom UIView and use auto layout with it. The auto layout relative to its parent view is working correctly, but its internal elements aren't being positioned or sized ...
0
votes
1
answer
46
views
How to auto resize tableview height + stackview
I'm trying to implement this feature:
Show title, description and image in each cell of a tableview.
However, the image could be nil.
Requirement is:
When image is nil, auto expand the label to fit ...
0
votes
0
answers
12
views
Containers not filling superview
My containers and UIViews are not filling the entire superview (for iPad) as I have them set to. You can see in the picture the gray area that is the superview that I would like it to fill. Any ideas?
0
votes
0
answers
38
views
How to make a horizontal UIStackView grow dynamically in height when content doesn't fit width?
I have a horizontal UIStackView with alignment center and distribution fill, that contains multiple UILabels. My issue is that because there are so many, they are being clipped instead of being placed ...
1
vote
1
answer
36
views
How can I make a view align it's center to the top of another view in SwiftUI?
So I want to have a view which overlaps another view, and has it's center Y aligned to the top of the view it's on top of.
The analogous layout constraints in UIKit would be the following:
let topView:...
0
votes
1
answer
32
views
How to increase the height of the UITextView inside the View
I have a textView on chatScreen. I need to know, how it possible to increase the height of the textView when we will write 3 or more lines. Here is how it looks in my app:
I've implemented this ...
0
votes
0
answers
54
views
Xcode 13 translatesAutoresizingMaskIntoConstraints crashes app
I have several views implemented programatically in the app without using storyboard.
let customView = UIView()
actionSheetHomeCall.view.addSubview(customView)
customView....
0
votes
2
answers
48
views
How to scale margin based on screen sizes with auto layout?
Imagine I have a UIImageView with a certain aspect ratio constraint (this handles the height/bottom constraint), pinned to superview's top, leading, trailing with 5pt in a 100pt width screen in XIB/...
-2
votes
1
answer
49
views
autolayout-conform UILabel with vertical text (objC or Swift)?
How would I create an UIView / UILabel with vertical text flow which would look like the red view of this example screen?
I have read about view.transform = CGAffineTransform(... which allows for ...
0
votes
1
answer
162
views
Collection view self-sizing cells issue in Compositional layout
I am using a collection view compositional layout to display a cell with two labels that can grow in height, depending on the content of the labels. Everything else in the cell is fixed.
I make a ...
0
votes
0
answers
43
views
Terminating app due to uncaught exception 'NSInvalidArgumentException' Unknown layout attribute'
I am trying to give vertical space constraint programatically for Admob native ads compenents by using NSLayoutConstraint.
I assigned nativeAdView in the ListTileNativeAdFactory class.
(I used this ...
1
vote
1
answer
38
views
UITableView edit mode appears on top of my views
edit mode problem
As you can see in the picture, when I enter the edit mode the delete button appears on top of all the views in the cell.
I assume this is because I am using programmatic UI with ...
0
votes
1
answer
61
views
How to reuse views more effectively and elegantly?
I have a page(UIView) with full content, and the other two pages contained particularly content of this UIView.
I want to code a view that completes the above three pages.The view goes like this:
The ...
1
vote
1
answer
96
views
iOS Layout Constraint Conflict in a TableView Cell
I'm getting a layout constraint error for a UILable in a UITableViewCell. My app is a to do list, and I have a UITableView that contains UITableViewCells of varying heights. If I drag a cell down to ...
-1
votes
1
answer
44
views
UItableView cell automatic resize
I've been trying to solve this problem for almost a whole week, im trying to implement a table cell in which there are 5 static parameters, and 3 floating ones (their sizes can be larger or smaller, ...
0
votes
1
answer
32
views
How to create a custom UIView with a subview inside, setting its size/position with AutoLayout programmatically?
I would like to create a custom UIView, say TestLabelView, which contains a label whose margin would be 16px.
It would look like this:
Here is how I tried to create this custom UIView and ...
0
votes
0
answers
72
views
Resize frame when text changes in figma auto layout frame
I'm trying to build a frame in Figma that resizes automatically when some text is changed, using auto layout. When the text is added to the frame, it resizes according to the current string in the ...
0
votes
0
answers
29
views
How to programmatically lay out stacking views and rotate?
I'd like to layout 3 imageViews programmatically by setting the frames manually. I am able to set up the middle image just fine but when trying to rotate the other two, the images's frames distort ...
0
votes
1
answer
92
views
Table view inside a cell of table view, however its frame height is 0
I encountered with a problem when was trying to build a table view inside a cell of another table view. I thought it’s pretty straightforward task...
Structure of app:
Collection view with workout ...
0
votes
0
answers
41
views
Autolayout warning "NSLayoutConstraint is being configured with a constant that exceeds internal limits"
I have a subclass of UIScrollView called MyScrollView. There is a subview called contentView inside MyScrollView. The width constraint is set to be the contentSize of MyScrollView.
private func ...
0
votes
1
answer
50
views
Setting centerXAnchor constraint with multiplier programmatically doesn't work
I am trying to set a horizontal center constraint of a view with multiplier programmatically. But what I get is always a constraint with 1.0 as the multiplier. This is what I did:
private func ...
0
votes
1
answer
32
views
Which lifecycle event to use for declaring layout constraints in a child view controller?
I have a simple parent view controller and I'm adding a child view controller to it. Here's the parent:
class ParentViewController: UIViewController {
private var childViewController: ...
0
votes
2
answers
69
views
swift Stack insertSubview & auto refresh layout problem
I would like to click and add subview at: index 3 position. But the constraint not update automatically. how can i refresh the layout when adding subview to uistack?
Thank you for your help very much
@...
0
votes
2
answers
92
views
UIImageView hugging & compression priority not working properly when new image is inserted
I'm trying to make view like this:
Everything works fine, but when I put image from API to that UIImageView, this happens:
UIImageView is stretching even with some Hugging Priority and Compression ...
0
votes
1
answer
26
views
Xcode - Autolayout and image changing size
I have an application with a screen with image of a person which has auto layout constraints applied to it.
When I navigate to and from this screen, the size of that image is always changing when I ...
0
votes
3
answers
34
views
Set view as percentage of width in portrait and percentage of height in landscape, in interface builder using autolayout
I am creating a launch screen that has a centered image. I want the image to be 0.7 of the width in portrait orientation and 0.7 of the height in landscape orientation, so the image is the same size ...
2
votes
2
answers
149
views
How to UICollectionReusableView stretch to Safe Area
I am trying to show HeaderView in my UICollectionView class and I use UICollectionReusableView class for that.
Actually I am showing HeaderView in my CollectionView but It does not reach to safe area.
...
-1
votes
1
answer
61
views
Device specific constraints Xcode 13
I'm having some issues setting up device specific constraints. I know how to use Vary for Traits, but it isn't advanced enough for what I need to do.
Basically, my app displays perfectly fine on any ...
1
vote
1
answer
57
views
How to create UICollectionView section Header which autosizes to label content + font size change?
I would like to add a section header to a UICollectionView which contains two lables to show a title and a info description. Both labels can show multi line texts and the header size should be ...
0
votes
2
answers
69
views
Swift - Update auto layout properties of UI components programmatically
To design and create my UI, I always use auto layouts and do it programmatically instead of using storyboard.
In every view class of mine, I have a method called
private func setupView(frame:CGRect) {
...
1
vote
1
answer
72
views
How do I know if I made auto-layout good enough to fit every device?
In my case:
When I set device to be Iphone SE and run simulator on Ipod touch 7th gen everything is normal and every element is where it should be.
But if I change device to iPhone 11 and run on same ...
0
votes
1
answer
66
views
Xcode autolayout constraint landscape orientation issue where view shrinks to zero size
I have a single view on screen that is constrained in the center x and y positions. It also has an aspect ratio to itself. The problem comes with the next constraints.
In portrait mode (compact width, ...
0
votes
1
answer
47
views
Last word in UILabel is lost
I have a simple UILabel with some usual constraints.
When I have a small enough text that fits in a line, it renders fine:
text = "Noodles Con Salsa Cremosa De algo"
When I have a big ...
1
vote
1
answer
76
views
UITableViewCell subview constraints problem - When are constraints updated in differen iOS Versions?
I have created a custom UITableViewCell which contains a subview that uses its layer settings to create round corners. The corner radius has to be half the height to be completely round.
Since the ...
0
votes
1
answer
59
views
How to change an UIView size according to its content?
So I have a checkbox and a label, I put them together within a UIView so I can use the checkbox and label as one component later on and for other projects, the thing is I want the view to change size ...
0
votes
1
answer
61
views
Collection View Stacking Items in Single Rows – Swift Xcode [duplicate]
Would someone please tell me why my collection view is stacking like this instead of side-by-side (until there's no more room and a new row has to be started)? I don't want them stacking with only one ...
1
vote
1
answer
194
views
setting leading margin of content to the leading of navigation bar large title in swift
I have a question about aligning content using autolayout.
I have a large navigation bar and one UIView right below the navigation bar. I want to set the UIView's leading anchor to the same leading ...
-2
votes
1
answer
66
views
How to trigger auto layout offscreen without adding the view to view hierarchy
My scenario is that I need to generate PNG Image data from an UIView whose layout I will setup myself. I create an UIView viewA in memory, which I will use to create PNG data. This happens in a ...
0
votes
1
answer
43
views
Actual screen coordinates of anchor layout constraint linked to a UIView in iOS?
I’m a novice working with an app that lets me bridge Lua to some objective C commands. Using that bridge, I’ve created some controls (e.g, a basic browser WKWebview) using the auto layout in iOS but ...