2,150 questions
0
votes
1
answer
176
views
how to rotate a object set in nslayout constraints
My swift code below is rotate a object at a 45 degree angle. My code below is having no effect on the rotation. I know I could rotate it i just create a frame but I need the constraints. I am not sure ...
1
vote
0
answers
247
views
How can you deallocate no-longer-needed NSLayoutConstraint objects that were programmatically created, to avoid a memory leak?
Something I find odd is once you create a constraint, the view hangs onto it forever, even if you explicitly remove it from the view's constraints collection (or set it's isActive to false which does ...
0
votes
1
answer
34
views
Why is my second button behaving different when using auto layout constraints?
I can not figure out why my button is behaving different when using auto layout constraints programmatically.
When setting the view that holds my cancelBtn every thing is working fine:
let ...
0
votes
0
answers
49
views
Same constraints different results
I gave a value of -8 to the "bottom to Safe Area bottom" constraints of 2 views, but they are not showing at the same distance from the Safe Area (seems like one needs -16 to equalize them).
...
1
vote
1
answer
238
views
Constraints issue
I am having trouble with my constraints. Any ideas would be appreciated!!
I have tried making a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints using the debugger to catch it, but I didn'...
0
votes
1
answer
68
views
why NSLayoutConstraint animation works only one time?
in my project I have a someView(of type UIView), that inside holderView(of type UIView).
someView have 2 state.
in state 1 the someView become large and in the step 2 the someView become small.
when ...
0
votes
0
answers
157
views
Remove label in view Swift5
I'm adding a label programatically in my view, in viewDidAppear:
var label : UILabel!
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
...........
label = ...
1
vote
1
answer
565
views
object not being constraint to bottom anchor of center y anchor
My swift code is trying to constraint a object to the bottom of the center y anchor. When the code is built and run on a iPad. That is not doing it. You can see the what is being displayed in the ...
0
votes
3
answers
1k
views
how to constraint something to the center top anchor
In my code below I am trying to constraint something to the top of the center point of the uiscreen. I have added a image of what I am looking for below. The code below is what I tried it pins it the ...
0
votes
0
answers
345
views
IOS: unknown crash on variable setter
I have a piece of code that is updating height constraint value.
The code is running perfectly on my device but I have received tons of crash report from Crashlytics.
I cannot reproduce the crash.
...
0
votes
2
answers
3k
views
Safe area not working in custom TabBarController's ViewController
In the didFinishLaunchingWithOptions of my app's AppDelegate, after initializing my UIWindow property, I set the root controller to a subclass of UITabBarController, in which I set the view ...
0
votes
2
answers
1k
views
How to programmatically add constraint center with multiplier
I do use multiplier with center constraints in the storyboard, now I want to do the same programmatically but can't figure out how to.
No, this thread does not help since the accepted answer is a ...
0
votes
2
answers
2k
views
Toggle Enabling UITextView Scroll After Max Number of Lines
I have a uitextview subview in an inputContainerView as it may appear in a messaging app.
Programmatically, on load, the height anchor of the uitextview is set when the inputContainerView is ...
0
votes
1
answer
173
views
Why my constraints doesn't work in my xib file
I am trying to add a button to a UIstackview, programmatically. All this is in fitxero XIB.
The button is created correctly, but when adding the constraints I get the following error:
2020-05-21 ...
0
votes
1
answer
53
views
slider only increasing imageview size not decreasing size
My swift code code below uses a slider to increase the size of the imageview. What I would like to do is when the slider moves from less than 0.5 the imageview gets smaller. If the value of the slider ...
-1
votes
1
answer
59
views
constrain imageview to 10 percent of area with space between top and leading anchor
I want to constraint my imageview to be spaced with a 20 percent gap from the leading anchor and 20 percent gap from the top anchor. You can see what I am looking for in the photo below. Somehow with ...
0
votes
2
answers
50
views
De activate constraints between 2 objects linking them together
My swift code as you can see in the gif below. Lets the user select one of the image views then use the slider to increase or decrease the size of that image view. The problem is when the image view ...
-1
votes
1
answer
96
views
Centering a navigation bar title (Swift)
I'm programming a little app and I'm facing a problem that I don't know how to solve it. The problem is that for phones (like iPhone7) with a smaller width of the screen size the title appears ...
0
votes
1
answer
155
views
Constraint objects to prevent them from moving when object changes size
As you can see in the gif below the light green objects moves south when the size of the dark green object is increased on the slide. What I want to do is when the dark green object size is increased ...
0
votes
1
answer
227
views
iOS Custom Keyboard Height Launching Glitch
I have created a custom keyboard and it works fine. I set the height constraint to be the same as the default keyboard. The issue is that when the keyboard first launches, it starts off below the ...
2
votes
1
answer
2k
views
Simple slide up animation on UIView using NSLayoutConstraints
I have spent a while trying to figure this out, but I just can't. There is probably something really simple I am missing here. I am trying to animate a view coming in from the bottom. This si the code ...
0
votes
4
answers
2k
views
Pinning a UIView to the top of the screen programaticaly
This may be a simple question but I am struggling to find an answer that explains itself on the internet. What is the swift equivalent of setting an element's "position: fixed" from CSS? I am trying ...
0
votes
1
answer
513
views
use slider to to change width and height of NSLAYOUT constraint imageview
My swift's code goal is to use a slider to increase decrease the size of a imageview. The imageview pic should be able to increase decrease size depending on what the value of slide slider is. When ...
1
vote
1
answer
189
views
Adding Constraint Programmatically Does Not Work
I'm setting constraints to image view programmatically like so:
imgScrollView = UIScrollView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
imgScrollView....
0
votes
1
answer
1k
views
Swift 5: centerXAnchor won't center my frame in the view
I'm stuck at the Consolidation IV challenge from hackingwithswift.com.
Right now I'm trying to create a hangman game. I thought to place placeholder labels based on the length of the answer word. ...
0
votes
1
answer
76
views
create loop to constraint width and height objects
What I want to do is create a loop that allows pic and slide to have the same width and height constraints. Since I am constraining 0.25 to all constraints. I assume there is a way to do this without ...
2
votes
1
answer
657
views
Is there any way to layout buttons in circular arrangement?
I'm trying to make a round button in the corner and when you press on it, 3 buttons pop up around it. Something like Pinterest's menu when you hold on a pin. I've looked up using UIBezierPath but it's ...
1
vote
1
answer
1k
views
Subview that clips to parent view in Swift
I'm trying to add a subview that would always have the same size as its parent, so that it would always resize if the parent size changes.
I was thinking about adding (top, bottom, leading, trailing) ...
0
votes
2
answers
2k
views
UIViewRepresentable hidden behind SwiftUI View
I recently asked (and got a valid answer) to a question related to this issue.
How do I get my UIViewRepresentable to correctly size for its content?
As I mentioned in the previous post,
I want to ...
1
vote
3
answers
2k
views
Autolayout of custom UITableViewCell finds conflicting constraints in Swift 5
I encountered the following problem. I was designing a custom UITableViewCell Design with Autolayout and everything worked perfectly. Xcode is not showing me any errors.
But when I do run the app on ...
0
votes
2
answers
7k
views
how to change priority of offset() and multipliedBy() in snapkit
I want to make the UIView's size: height = (width - 100) * 0.5, so the code like this:
view.snp.makeConstraints {
$0.top.left.right.equalTo(0)
$0.height.equalTo(view.snp.width).offset(-100)....
-2
votes
1
answer
121
views
how to create function that return NSLayoutConstraint
hey developer I want to ask, I have a repeated create constraint and then I try to create a function that return NSLayoutConstraint. then I got confuse what should I return since there is 3 different ...
0
votes
2
answers
435
views
Use AutoLayout to position percentage-positioned subviews inside UIView
I'm working with some JSON that is giving me a series of views and subviews to lay out inside a UIView, and I'm wanting to use AutoLayout to achieve it. Here's an example of the JSON:
"component": {
...
2
votes
2
answers
168
views
Apply and animate many constraints to outlet collection of uiviews
I have an outlet collection of labels. The labels are in stack views parented by a stack view. When the view loads I'd like to have each label fade in and move slightly to the right one after the ...
1
vote
2
answers
258
views
ios Swift tableView dynamic cells constraints for labels and image programatically
I have labels and an image. I want labels above image. And image without leading and trailing margin constraints.
I have tried the following constraints but can't seem to get it right. And the row ...
0
votes
1
answer
78
views
Constraints Problems with table view cell
I have problems with constraints in table view cell. As you can see in the image above , I tried to constrain the label on the far right so that label will be closer to the right right edge. But that ...
-1
votes
1
answer
56
views
Swift: Constrain object to and point within a circular NSLayoutConstraint? Circle anchor?
Within a view controller, I have a UIView (backgroundCircle) and a UILabel. The UILabel is moving based on motionManager.startAccelerometerUpdates data. Using this data, I am animating the label....
0
votes
2
answers
222
views
Programmatic constraints cut the bottom of my label off
I have a Nib file with a root UITableViewCell and child UILabel that I anchor at run time using programmatic constraints
lblAccountItemTitle.translatesAutoresizingMaskIntoConstraints = false
...
0
votes
1
answer
779
views
Align UISwitch to align to center
My swift code below is trying to get the uisiwtch to appear in the center of the screen. As you can see in my photo below. As You can see in the image below. The switch is taking up only a small part ...
0
votes
1
answer
60
views
Constraints are not being applied as expected
I have a custom UITextField that I use in multiple places, but am having a strange issue with it's constraints on only a few of the pages I use it. The custom class has a few things I add upon ...
0
votes
1
answer
91
views
space position objects by proportion
My swift code below is positioning objects. I want both objects to be to cover 10 percent of the x axis each. So the first object which is fight[0].image and the 2nd object is fight1.image. As you can ...
5
votes
4
answers
3k
views
Swift - Programmatically refresh constraints
My VC starts with stackView attached with Align Bottom to Safe Area .
I have tabBar, but in the beginning is hidden tabBar.isHidden = true.
Later when the tabBar appears, it hides the stackView
So ...
0
votes
1
answer
615
views
Unable to satisfy constraints with nested stack views
I'm slowly going insane trying to debug an Unable to satisfy constraints warning in the console, which appears when I transition from iPhone portrait to iPhone landscape. I'm working on a Dashboard-...
0
votes
1
answer
473
views
Why am I getting Nil Layout Anchor warning while presenting my custom UIAlert?
I have a custom UIAlert where I set the content view controller to my own custom VC. The alert functions properly, but I keep getting this error: "A constraint factory method was passed a nil layout ...
-1
votes
2
answers
2k
views
Equal Height constraints between different UIStackView's subviews
I have a constraint scenario which works perfectly when built through interface builder but I cannot make it through code. The screen layout is the following:
A Horizontal UIStackView with multiple ...
-1
votes
3
answers
161
views
Entering text into textfield causing uipangesture object to move back to its orginal position
My swift code below has a image view connected to a pangesture. When something is entered into a textfield when after the image view is moved. The image view reverts back to its original position.The ...
0
votes
1
answer
326
views
Can layoutIfNeeded be called only once per loading the view - e.g. viewDidLoad?
A view's height in my view controller needs to change as the user interacts with the application. Sometimes the view needs to be larger in height and other times it needs to be shorter depending on ...
0
votes
1
answer
103
views
Why UITableViewCell dynamic view constraint not working properly?
I am trying to create UIButton inside the UITableViewCell using following way
UITableView configuration :
self.tableView.estimatedRowHeight = 1
self.tableView.rowHeight = UITableView....
3
votes
1
answer
230
views
UIKitCore layoutGuides deadlock
I am creating a popup menu. It has a UIPresentationController that calculates frameOfPresentedViewInContainerView based on presented view controller's view size before showing it.
Presented view ...
0
votes
1
answer
49
views
use uipangesture on a nslayout constraint
My swift code below is using nslayout constraints in view did load. I have tried to place a uipangestureRecognizer on a imageview. To get the image view to move around the uiview controller. Right now ...