Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
363 views

I have a button I created in my storyboard, but have a custom UITextField that needs to be implemented in code, I am trying to place the text field so that it's 20 pixels above the button, but I am ...
Noah Iarrobino's user avatar
0 votes
1 answer
124 views

I have create a UIView extension which should move subviews into another (sub-)view while keeping the constraints intact. The constraints between the subviews and the the view as well as the ...
Andrei Herford's user avatar
0 votes
2 answers
1k views

I have a simple UICollectionView in a view controller. I am animating the top constraint of the collection view via a button. On the FIRST button tap, the collection view cells are animating quite ...
iqra's user avatar
  • 1,301
0 votes
1 answer
1k views

I have a collection view in which I'm populating images that I get from the backend. I'm using AutoLayout and I've statically set the imageview's height as 180 and width as screen width. But I've ...
Akash Neeli's user avatar
-1 votes
1 answer
122 views

I am currently getting to grips with UIKit and trying to build a simple game to do so. The first part I am struggling to understanding is auto layout, the necessary constraints and their behaviour, as ...
SanMu's user avatar
  • 784
0 votes
2 answers
662 views

I'm trying to change the height of my menu view so that it opens, but when I add the IBOutlet of the NSLayoutConstraint it keeps crashing my app with the same error code. I Triple checked that the ...
Jef Janssen's user avatar
1 vote
1 answer
216 views

I have a constraint in my view controller that gets deactivated by the system for some reason when the app goes into the background and then coming back to foreground. I haven't been able to pinpoint ...
Peter Warbo's user avatar
  • 11.9k
0 votes
1 answer
912 views

I have followed this answer to instantiate a view from a XIB file: extension UIView { class func fromNib(named: String? = nil) -> Self { let name = named ?? "\(Self.self)" ...
Dannis Case's user avatar
0 votes
1 answer
447 views

I have a mini game in my project where you have to guess a flag of a country, I don't use Interface Builder, all UI is written in code. When user taps one of the flags I load new set of countries to ...
adseeAnn's user avatar
1 vote
1 answer
450 views

When I click on of the five textfield, the picker view comes up but this error comes up. when you click on the lower two textfields the picker view doesn't´t come up. If I make this whole thing ...
DragonCat - Kiara's user avatar
2 votes
2 answers
1k views

So I have a UIButton and I'm setting the title in it to a string that is dynamic in length. I want the width of the titleLabel to be half of the screen width. I've tried using .sizeToFit() but this ...
nickcoding2's user avatar
0 votes
1 answer
40 views

I am trying to align two UIBarButtonItems vertically on the right side of my UINavigationBar. I am using a custom view, and aligning two buttons within that. Here is the code: let ...
goatofanerd's user avatar
0 votes
1 answer
1k views

I'm using the following layout as a custom popup UIView in Xcode 13 (the white background is transparent): When the screen orientation is changed to landscape mode, the constraint at the top and ...
Neph's user avatar
  • 2,013
0 votes
1 answer
703 views

I have a container group (the radio group) that contains a UIStackView, and that stack view contains a bunch of items that can have varied sizes, depending on their label content. They have two labels ...
lufinkey's user avatar
  • 390
0 votes
1 answer
138 views

let imageView = UIImageView(image: UIImage(named: "Loading")) imageView.frame = CGRect(x: 100, y: 100, width: 200, height: 200) imageView.center = self.view.center self.view.addSubview(...
Code cracker's user avatar
  • 3,176
0 votes
1 answer
81 views

I have convenience extension functions that allow me to add constraints to UIViews: enum Constraint : String { case top = "topAnchor" case bottom = "bottomAnchor" ...
Raildex's user avatar
  • 5,428
0 votes
2 answers
544 views

I've dealt with programmatically creating constraints, but something isn't working this time and I can't figure out what it is. override func viewDidLoad() { super.viewDidLoad() let imageview ...
Kenny Wyland's user avatar
0 votes
1 answer
74 views

What's needed to stack multiple UICollectionView's vertically on the same UIViewController? I have added my code below and the issue that I am having is I do not see the StoryCollectionView. When I ...
Brandon B's user avatar
0 votes
1 answer
563 views

I am working on view which will have a label and few buttons. The length of view should depend upon the text in label. I have tried to place label and button in the view vertically and add constraints ...
mars_dev's user avatar
  • 649
2 votes
2 answers
706 views

Below code is not working as expected. the InfoLabel is not added to the view. I am calling the below methods in the order mentioned from viewDidLoad. Any quick help/insights will be great. Thanks! ...
Manikandan.Gopal's user avatar
2 votes
1 answer
725 views

I have a simple view attached to the bottom of view controller: let view = UIView() view.backgroundColor = .gray view.translatesAutoresizingMaskIntoConstraints = false let viewBottomPositionConstraint ...
Phil Dukhov's user avatar
0 votes
3 answers
640 views

Background I’m trying to create a UIButton with a 300px width and 200px height. Then, I’m trying to position that UIButton centred horizontally and 50 pixels from the bottom. When running the code in ...
user4806509's user avatar
  • 3,011
0 votes
3 answers
631 views

Update: Thanks everyone for the unique approaches. Appreciate your insights. Background: I have written some code below in Xcode Swift 5 that creates four equal sized rectangles that resize depending ...
user4806509's user avatar
  • 3,011
-1 votes
1 answer
518 views

Background: When rotating the device, the view myView becomes letterboxed instead of resizing to fit the screen, see image below. On the storyboard, centreX and centreY constraints are set. In the ...
user4806509's user avatar
  • 3,011
0 votes
1 answer
219 views

I want to append 20 constant value to nslayoutconstraint, how can I do that ?? Let moduleConstraint = module.bottomAnchor.constraint(equalTo:mainScroll.safeAreaLayoutGuide.bottomAnchor)
Rehan Ali Khan's user avatar
-1 votes
1 answer
478 views

I added leading | trailing | top | height constraints but the view is not visible. let view = UIView() view.backgroundColor = .orange self.addSubview(view) NSLayoutConstraint.activate([ ...
Code cracker's user avatar
  • 3,176
0 votes
1 answer
380 views

I have a horizontal UICollectionView with green background (attached image) and I`d like to adjust its width depending on how many cells are available. After that, the button needs to be attached to ...
Russ's user avatar
  • 83
0 votes
1 answer
537 views

I'm working on a project in UIKit, without storyboards (only programmatic layout constraints) and, following this, I have a custom view controller like this: @objc public class testController: ...
Evan's user avatar
  • 2,096
0 votes
1 answer
189 views

I have a stackview whose height is 250. I want to program: When the button is tapped, the stack should go to the top of screen. Then after a few seconds it should go back to its height of 250, which ...
deathAdder's user avatar
0 votes
0 answers
65 views

I have a simple ViewController with a UITextView inside of a UIStackView. I've also stored an NSLayoutConstraint which is the bottom anchor of the stackView. When the textView becomes first responder ...
Sotiris Kaniras's user avatar
0 votes
1 answer
48 views

I have an iOS view consisting of a collectionView with a headerView. The view displays fine, but when I rotate the device (iPad), the header elements get duplicated and don't fit correctly. The output ...
cesarcarlos's user avatar
  • 1,469
6 votes
1 answer
2k views

I have a ScrollViewReader and the scrollTo method works. proxy.scrollTo(target, anchor: .top) The item which is scrolled to is completely aligned with the .top-Anchor. Now I want to include the ...
TheMultiplexer's user avatar
3 votes
3 answers
493 views

I would like to programmatically move all subviews of a UIView to another UIView while keeping all constraints between the subviews to each other and to the (new) parent intact. What is the "...
Andrei Herford's user avatar
1 vote
0 answers
68 views

Whenever I run my iOS app on a device that has a home bar, the bottom of a UIScrollView or one of its descendants will render too low. My app has a bottom navigation. I made the scroll view ...
Martin Braun's user avatar
  • 12.8k
0 votes
1 answer
470 views

I have two labels in a UITableViewCell subclass. I want both labels to be multiline labels, so I have set the number of lines to zero for both of the labels. But the problem is that the labels keep ...
ashipma's user avatar
  • 469
0 votes
1 answer
116 views

I have two labels in a UITableViewCell subclass. I want both labels to be multiline labels, so I have set the number of lines to zero for both of them. But the problem is that my table view cell is ...
ashipma's user avatar
  • 469
1 vote
1 answer
98 views

I have a UITableViewCell that has two columns in it. Each column is a UILabel and each label is multiline (numberOfLines = 0). What I would like is to have the table view cell vertically sized based ...
ashipma's user avatar
  • 469
1 vote
1 answer
94 views

In my UIView subclass, I have one image view and three labels: let imageView = UIImageView() let firstLabel = UILabel() let secondLabel = UILabel() let thirdLabel = UILabel() The image and texts are ...
AJP's user avatar
  • 67
1 vote
0 answers
117 views

I have an InputAccessoryView with a single button in. However, I am getting the following output. I have set up my InputAccessoryView in my ViewController as below; lazy var customInputView: ...
David Henry's user avatar
  • 3,090
0 votes
2 answers
57 views

Hi Please take a look at the following mockup: I wanted to know how I can create the constraint from above: V2.top = C1.top + n * V1.height Because this is not something like the default equation ...
אורי orihpt's user avatar
0 votes
1 answer
288 views

I am creating a custom UIView in swift, here is the code for the custom View, class FormField: UIView { @IBOutlet var viewLabel : UILabel! @IBOutlet var textField: UITextField! @...
Easy Coder's user avatar
2 votes
1 answer
773 views

I'm making an iOS application, creating the UI programmatically, so far what I'm trying to do is display a map with MapKit inside one tab of UITabBarController, and I'm trying to make the map to use ...
Frakcool's user avatar
  • 11.2k
-1 votes
3 answers
1k views

I am practicing auto-layout programmatically. I want to put a UIView centered in the controller whose width will be 4/5 in portrait mode but when it will go to the landscape mode, I need the height to ...
Natasha's user avatar
  • 6,913
1 vote
2 answers
1k views

Why do some developers add constraints like this: NSLayoutConstraint(item: myView, attribute: .right, relatedBy: .equal, toItem: view, attribute: .right, multiplier: 1.0, constant: 20.0).isActive = ...
shadow of arman's user avatar
0 votes
0 answers
391 views

I am trying to animate a view in a ViewController using Layout Constraints. My goal is to transform the view's height from 0 to finalHeight in order to make the view "appears" from the ...
neteot's user avatar
  • 943
1 vote
2 answers
3k views

I am trying to animate constraints in a custom UIView. The ending layout is correct, but I cannot get UIView.animate to work correctly, and I have seen that everyone is calling self.view....
bhersh90's user avatar
-1 votes
1 answer
23 views

I want to add constraints to a view programmatically. This is what I did: extension UIView { func bottomToTop(other: UIView) { self.translatesAutoresizingMaskIntoConstraints = false other....
Lena Bru's user avatar
  • 14k
0 votes
1 answer
485 views

@objc func buttonRoundPlayer(){ view?.addSubview(buttonRound) buttonRound.setTitle("Jump", for: .normal) buttonRound.addTarget(self, action: #selector(roundhandle), for:...
OptiCode22's user avatar
0 votes
1 answer
360 views

Swift 5/Xcode 12.4 My app uses a UIScrollView to zoom its child UIImageView (which is filled through code). This part works but the ScrollView keeps complaining in XIB that it's missing constraints ...
Neph's user avatar
  • 2,013
6 votes
1 answer
813 views

I have a strange issue on updating a NSLayoutConstraint constant value. I have a view controller with a custom UIView (which acts as a bottom sheet / card). Inside my UIView class I am updating the ...
iqra's user avatar
  • 1,301

1
2
3 4 5
43