2,150 questions
1
vote
0
answers
55
views
Multi-line title in UIButton in a UITableViewHeaderFooterView causes UIViewAlertForUnsatisfiableConstraints warnings
I need to show occasional long texts in a UIButton in the section header of my UITableView. The following simple example code shows the issue:
import UIKit
import SnapKit
class ViewController: ...
0
votes
0
answers
56
views
NSTextView Breaks Layout Constraints on Holding Down Key (Press and Hold)
I have a simple NSTextView inside a scroll view, as follows:
self.suggestionTextView = NSTextView()
self.suggestionTextView.isEditable = true
self....
1
vote
1
answer
113
views
iOS Autolayout - unable to have height be lessThanOrEqualTo
I am using SnapKit for auto layout in my iOS app.
I need to show an image view at the very top of the screen. It will have an image of dynamic height and width. I need its top edge to be aligned with ...
1
vote
0
answers
145
views
UIViewControllerRepresentable loses its alignment when integrated with other SwiftUI dynamic views
Targets:
Tested with
iPhone 16 Pro with iOS 18.0 (Simulator)
iPhone 6s with iOS 15.8.1 (Physical device)
I have an UIKit UIViewController component (instance of UIPageViewController, repo: here).
I'...
1
vote
0
answers
68
views
NSView equivalent to UIView's systemLayoutSizeFitting
How can I calculate the optimal size of a NSView based on its current constraints and a target size?
UIView provides:
func systemLayoutSizeFitting(_ targetSize: CGSize) -> CGSize
func ...
-1
votes
1
answer
126
views
How to get Spring Animations with Constraints to behave properly?
Trying to get a spring animation to work properly. I made a git repo. Basically the red view is constrained as follows:
let ac = brokenView.widthAnchor.constraint(equalTo: brokenView.heightAnchor, ...
-2
votes
2
answers
117
views
How do you, or can you, create and/or "adjust" an NSLayoutAnchor property?
Say you have some large complex custom view,
lazy var pinkThing: ..
lazy var greenThing: ..
And you want to
///For upstream views to use as they wish
var pinkCenterY: NSLayoutYAxisAnchor {
return ...
0
votes
1
answer
83
views
I was trying to update the height constraint of my view during an animation. Its not getting updated why..?
Here is how i have configured the profile view,
-(void)addProfileView
{
if(!_profileView)
{
_profileView = [ProfileView new];
_profileView.clipsToBounds = YES;
...
0
votes
1
answer
50
views
Swift drawRect on UICollectionView subview with layout constraints draws in unexpected location
I am trying to draw onto a subview (subclass of UIView) that I have added to a UICollectionViewCell's contentView. I did this by implementing a drawRect function to draw a very simple cross in the ...
0
votes
1
answer
355
views
Adding Constraints to view, whose topAnchor's is bottomAnchor of UIView with dynamic height
I've created a UIView, which has buttons in it. I set the constraints like this :
NSLayoutConstraint.activate([
sampleView.topAnchor.constraint(equalTo: topView.bottomAnchor, constant: 20),
...
0
votes
1
answer
631
views
How to simultaneously satisfy constraints in Swift
I am developing a Log-In screen using XCode 15.2 and the latest version of SwiftUI that is shipped in Xcode.
The Simulator I use is the iPhone 15 Pro.
The Log-In Screen has two TextFields one contains ...
1
vote
1
answer
63
views
setup all of the properties of the stack view
I'm using an SF symbol image into a UIImageView. I have given the constrains as well. What I have seen running the same code into different simulators actually increases the width of the image but I ...
0
votes
1
answer
74
views
Animation is not showing as expected in swift
I have taken image and I want flyView to be drop from top middle to 200 from top and vanishes. for that tried like this
code: here I have given constraints for flyView as flyView.centerXAnchor and ...
0
votes
1
answer
406
views
How do we constrain the layout of two Views to have the same position and size in SwiftUI?
I am a mildly experienced UIKit/AppKit developer, but I am just getting started using SwiftUI. In UIKit it is straight forward to constrain two UIView's to have the same size and position using ...
0
votes
1
answer
46
views
UITableViewCell Label's content missing
I am setting a tableView but when running the app, the label's content is not stable, sometimes it shows full content, sometimes it doesn't. Looking for advise.
I attached the images for .xib setup ...
0
votes
1
answer
148
views
Using modal view frame size in subview layout constraints
Problem: I am having some issues using the correct frame values to simulate viewport percentages when sizing subviews of a modal view-controller. I would rather size subviews using layout constraints ...
0
votes
1
answer
541
views
Unable to activate constraint with anchors.... because they have no common ancestor
I am attempting to create a Swift-based UI programmatically that resembles the layout shown below
Below is my view hierarchy which I created using xib. Now I'm attempting to achieve the same through ...
0
votes
0
answers
73
views
How does Auto-Layout resolve constraints internally?
IMPORTANT: I know how to use Auto-Layout. How to use it has been asked before already and this is not a duplicate of that question.
Auto-Layout is Apple’s cross-platform constraint-based layout system....
0
votes
1
answer
89
views
Default height of UIView with constraints (auto layout)
When you build an UI programatically with swift and constraints, you can notice that most views have some height or width, and you don't need to define it. For example UILabel, if you make constraints ...
-1
votes
1
answer
230
views
Can't activate NSLayoutConstraint
I'm trying to set up UI for ViewController through NSLayoutConstraint. Here's the code I'm using:
class ProfileViewController: UIViewController {
private var profileUser = katyPerry
...
0
votes
1
answer
66
views
Adding a subviews than can change each constraint
What I'm trying to do in my project is to transfer images to the screen according to the location data coming from the firebase( for example x = 5 , y = 10, width = 30, height = 50). For example, let'...
0
votes
0
answers
80
views
collectionView height not set According to content Height
how to use two collectionview inside one ViewController with UiCollectionView Height set two fixed height and may varied according to content size ? BY using NSLayoutConstraint in UIKit.please help me ...
3
votes
1
answer
3k
views
UIViewRepresentable ignores constraints of wrapped UIView
I have subclass of UIButton, which defines it's height inside by using NSLayoutConstraints, which I need to reuse in SwiftUI view by wrapping it into UIViewRepresentable.
So here is the code:
struct ...
0
votes
1
answer
30
views
objective-c ios auto layout NSLayoutConstraint
UIView* headerView = [[UIView alloc] initWithFrame:CGRectMake(8, 8, frameWidth, frameHeight)];
headerView.backgroundColor = UIColorFromRGB(0x5F70B9);
UIImage* leftImage = [UIImage ...
0
votes
3
answers
457
views
How do you remove constraint centerXAnchor?
I have a button placed in the center using centerXAnchor of superview, but now I have to change the position of the button from centerX to align leading from code. However, it's not moving to the left....
0
votes
2
answers
170
views
NSLayoutConstraint animation glitch
I've decided to switch to constraints and face up with animation problems. In autoresizing mask world everything works fine. UIView is attached to right top. Content inside use autoresizing mask.
...
0
votes
1
answer
46
views
The difference between viewDidLayoutSubviews and NSLayoutConstraint
Please explain the difference.
I watch the lesson on YouTube (LINK)
The guy uses viewDidLayoutSubviews when he could have used NSLayoutConstraint.
override func viewDidLayoutSubviews() {
super....
1
vote
1
answer
1k
views
NSLayoutConstraint for setting Min and Max view width
What I want to achieve in AppKit (not in SwiftUI): [GIF] (example in SwiftUI)
The NSWindow max width should not be limited to the NSTextField max width.
The NSWindow min width should be limited to ...
0
votes
0
answers
74
views
TableView height is not adopting dynamic size
I have table view in which I have another table view. Actually I make dynamic section with cells coming from backend.
The problem is that is not showing the last cell.
Here is the main table view ...
1
vote
1
answer
2k
views
ImageView inside horizontal StackView is not respecting constraint height
I have a horizontal UIStackView: on the left there's a UIImageView and on the right labels and buttons.
I hardcoded the imageview to be 60x60 (with constraints). However, because the right side needs ...
0
votes
1
answer
120
views
Swift 5 iOS TableViewCell Items Horizontal Overlapping
I am writing a programatic table view with custom cells for an iPad only app, I have the data coming through and the layout almost there but I am struggling with the widths of UILabel in the ...
0
votes
2
answers
413
views
The UI search bar disappears when clicked( possibly NSLayoutConstraint issue)
A quick question, for what should've been an easy implementation.
Im trying to implement a UISearchcontroller and the UIsearchbar property when trying to customize it and set constraints behaves ...
0
votes
2
answers
1k
views
Set Constraints to Labels So That One is At Leading Side and The Other at Trailing Side in Swift
I am programmatically adding a label and a button in Swift. I want the label to be at leading side and the button at trailing side. This is what I did so far:
let view = UIView.init(frame: CGRect.init(...
0
votes
0
answers
53
views
LazyVGrid NSLayoutConstraint conflict
I have a LazyVGrid with minimum width and height for the cells, and the cells have a 10p padding constraint. I get this type of error :
(
"<NSAutoresizingMaskLayoutConstraint:0x282eb3020 h=...
1
vote
1
answer
891
views
Snapkit LayoutConstraints Unable to simultaneously satisfy constraints
I have simple UITableView and custom UITablViewCell in my project, which created programmatically and use SnapKit for auto layout its.
When I run app, everything work fine and get some ...
0
votes
1
answer
84
views
Why these NSView subclass instances do not get initialised [Objective-C]?
I am trying to understand how NSLayoutAnchor works in Objective-C by converting a simple Swift app to it. The Swift app creates an NSView subclass which sets its layer's background color to a randomly ...
-1
votes
1
answer
916
views
Programmatically set constraints for uitableviewcell with uilabel and uiimageview
I am trying to build my tableview with custom UITableViewCell but facing some issues in coinstraints. Following is my custom UITablviewCell class:
class MovieCell: UITableViewCell {
static let ...
1
vote
2
answers
710
views
Layout not working when container view controller dynamically changes child view controller
I have a MainViewController that contains a ContainerViewController.
The ContainerViewController starts out showing childViewControllerA, and dynamically switches it out to childViewControllerB when a ...
1
vote
1
answer
132
views
Prevent cell content from "jumping" when applying constraint
I have a subclassed UICollectionViewCell and I want it to expand when tapped.
To achieve this, I put the title into a view ("titleStack") and the body into a separate view ("bodyStack&...
0
votes
1
answer
247
views
Custom UIView from XIB not resizing
My aim is to create custom image for MKAnnotationView.
The number of "service items" in image can be different for every annotation -> it should be possible to dynamically change items ...
-2
votes
1
answer
98
views
Swift Programmatic UI where can I put all the constraints?
So I started to learn Programmatic UI after I struggled with Storyboard.
I basically figured out where can I store the View's code such as button, textfield, etc.
But my problem is I don't want to see ...
2
votes
1
answer
1k
views
Stretchy Header with UIPageViewController
My problem seems obvious and duplicated but I can't manage to make it work.
I'm trying to achieve the famous stretchy header effect (image's top side stuck to top of UIScrollView when scrolling), but ...
0
votes
2
answers
244
views
I want to set label & Imageview in centre of myView but App crashing after adding some constraints
Error:-
Thread 1: "Unable to activate constraint with anchors <NSLayoutXAxisAnchor:0x280af8500 \"UILabel:0x103dc4fa0.centerX\"> and <NSLayoutXAxisAnchor:0x280af89c0 \"...
0
votes
0
answers
134
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 ...
0
votes
1
answer
141
views
How to set width of a UITableView equal to the maximum cells' width inside of it?
I have a table view and I using a custom cell which has 3 UI elements as subviews. I have made my UIelements which are labels to shrink as per there content size. Now my problem is to set cell to ...
-2
votes
1
answer
650
views
UIAlertController shown on iPhone, not on iPad
I'm presenting a UIAlertController action sheet on a view controller. This works fine on an iPhone. On an iPad I see nothing, but the console warns me about layout constraints which seem to set its ...
4
votes
1
answer
773
views
Getting Warning for UI Layout in iOS "Unable to simultaneously satisfy constraints"
I have created UITableviewCell programmatically and trying to load in table view
Cell has just one imageView and UIlabel.
Although the UI looks fine , but I am seeing this warning :
Unable to ...
1
vote
1
answer
315
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
49
views
Wrong layout inside cell
I'm trying to create a calendar with collection view but i have a small problem:
Here my code for cell's ui configuration:
addSubview(dateLabel)
addSubview(moneyLabel)
NSLayoutConstraint....
3
votes
1
answer
175
views
UITableView appears stuck under Nav Bar when configured in Storyboard (maybe corrupted?) but not when configured with code
I know it might be hard to diagnose this, but I'll try to give all the relevant info I can without overwhelming the post but it needs a ton of info. I've done this a hundred times over the last decade ...