Skip to main content
Filter by
Sorted by
Tagged with
573 votes
19 answers
706k views

I'm trying to figure this out since last week without going any step further. Ok, so I need to apply some constraints programmatically in Swift to a UIView using this code: var new_view:UIView! = ...
Sara Canducci's user avatar
252 votes
3 answers
108k views

I know that the auto layout chain consists in basically 3 different process. updating constraints layout views (here is where we get calculation of frames) display What's is not totally clear to me is ...
Andrea's user avatar
  • 26.4k
187 votes
17 answers
119k views

I have a view that is laid out completely using auto layout programmatically. I have a UITextView in the middle of the view with items above and below it. Everything works fine, but I want to be able ...
tharris's user avatar
  • 2,252
183 votes
19 answers
107k views

I created two views in one superview, and then added constraints between views: _indicatorConstrainWidth = [NSLayoutConstraint constraintWithItem:self.view1 attribute:NSLayoutAttributeWidth relatedBy:...
Bimawa's user avatar
  • 3,760
161 votes
17 answers
159k views

Below is the error message I receive in the debug area. It runs fine and nothing is wrong except that I receive this error. Would this prevent apple accepting the app? How do I fix it? 2012-07-26 01:...
Johnny Cox's user avatar
  • 1,883
143 votes
10 answers
238k views

I have a UIView and I set the constraints using Xcode Interface Builder. Now I need to update that UIView instance's height constant programmatically. There is a function that goes like myUIView....
Chris Mikkelsen's user avatar
132 votes
6 answers
26k views

The question I have is simple but I couldn't find any information in the documentation. What happens with layout constraints when a view is removed from the view hierarchy (or moved to another view)? ...
Sulthan's user avatar
  • 130k
129 votes
6 answers
85k views

I've never worked with autolayout constraints before. I have a small new app I'm working on and noticed that the NIB's views are defaulting to autolayout. So, I figured I'd take the opportunity to ...
Meltemi's user avatar
  • 38.4k
128 votes
18 answers
173k views

I would like the UICollectionView (The red one) to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of empty space. What I tried is ...
charbinary's user avatar
  • 1,905
120 votes
8 answers
106k views

I've set up multiple sets of constraints in IB, and I'd like to programmatically toggle between them depending on some state. There's a constraintsA outlet collection all of which are marked as ...
tybro0103's user avatar
  • 49.9k
115 votes
7 answers
49k views

I have a UIView in my UIViewController in storyboard which I want to add a constraint on to space that view a distance from the top edge. Now, when I do the usual by ctrl + drag to the ViewController'...
Arbitur's user avatar
  • 39.1k
109 votes
7 answers
141k views

I have a UITableViewController that doesn't display any sections if there is nothing to show. I've added a label to indicate to the user that there is nothing to display with this code: label = ...
Mario A Guzman's user avatar
108 votes
7 answers
132k views

I have used auto layout for my view controllers. I have set the V and H positions in constraints, but I want to know how can I increase my button size when it changes to 5s, 6 and 6 Plus. This is the ...
IRD's user avatar
  • 1,167
106 votes
10 answers
64k views

I'm using auto layout constraints programmatically to layout my custom UITableView cells and I'm correctly defining the cell sizes in tableView:heightForRowAtIndexPath: It's working just fine on iOS6 ...
Alexis's user avatar
  • 16.9k
105 votes
1 answer
32k views

Possible Duplicate: presentViewController: crash on iOS 6 (AutoLayout) I'm getting this error when clicking on a button in my app: 2012-06-28 21:43:36.860 AppName[2403:707] *** Terminating app ...
tracifycray's user avatar
  • 1,423
95 votes
4 answers
51k views

I can't find a way to create a 'square' constraint, meaning 'width equals height' in Interface Builder. I guess it's possible to add such constraint programmatically. Is there something I can do in IB?...
DemoniacDeath's user avatar
86 votes
11 answers
96k views

I've been looking for a lot of snippets in the net and I still can't find the answer to my problem. My question is I have a scrollView(SV) and I want to add a button inside scrollView(SV) ...
Bordz's user avatar
  • 2,810
83 votes
8 answers
54k views

I have a custom UIView subclass which is being initialized via a nib. In -awakeFromNib, I'm creating a subview and attempting to center it in its superview. [self setInteralView: [[UIView alloc] ...
Patrick Perini's user avatar
77 votes
11 answers
115k views

I have gone through and removed every single user constraint yet I am still getting the following error ONLY after I rotate the device. I have absolutely no clue why though. Does anyone have any ideas?...
user avatar
77 votes
3 answers
57k views

I've read the documentation. But I'm still not sure when I need to set it to true. In the code below if I set it to false I won't see the header at all. If I leave it as true, then everything is fine. ...
mfaani's user avatar
  • 37.1k
73 votes
8 answers
79k views

I want my UIImageView to grow or shrink depending on the size of what the actual image it's displaying is. But I want it to stay vertically centered and 10pts from the leading edge of the superview. ...
Doug Smith's user avatar
  • 29.5k
68 votes
13 answers
14k views

I have a storyboard with Autolayout and Size Classes. Pretty complicated layout, and unfortunately I can't really pin down how to reproduce the problem in a new project. But the view in question is ...
Matthias Bauch's user avatar
65 votes
5 answers
38k views

I just finished an app on iOS 6 and bought a developer account a week ago so haven't had much time playing with the iOS 7 SDK. Just downloaded the Golden Master version and trying to upgrade my app to ...
AJ112's user avatar
  • 5,291
65 votes
4 answers
28k views

Apple's documentation on creating Auto Layout constraints between a view and one of the layout guides only shows an example using VFL. Is there any way to create these constraints programmatically ...
smileyborg's user avatar
  • 30.5k
63 votes
5 answers
83k views

I am new in auto layout. I have done all of my project from xib file, but now I faced a problem where I have to update an view's height programmatically. I have tried below but now working. [[self ...
Tapas Pal's user avatar
  • 7,257
62 votes
5 answers
44k views

At the moment, I'm using a UITableView along with other views that are contained in a UIScrollView. I want the UITableView to have its height to be the same as its content height. To complicate ...
Matt Delves's user avatar
  • 1,605
59 votes
6 answers
16k views

I have a UIView subclass that draws a circle whose radius changes (with nice bouncy animations). The view is deciding the size of the circle. I want this UIView subclass to change its frame size to ...
Loz's user avatar
  • 2,228
57 votes
9 answers
62k views

How do I properly resize a UICollectionView so that it fully displays its contents? I have tried many things, including setting its frame, calling reloadData and invalidating the layout: self....
Martijn de Milliano's user avatar
55 votes
3 answers
35k views

What is happening now with constraints in SwiftUI? Do View types adapt automatically for bigger devices etc. or what should we have to do instead?
SwiftiSwift's user avatar
  • 8,988
53 votes
7 answers
17k views

I keep getting 'Unable to simultaneously satisfy constraints' exceptions (Xcode 5, iOS 7, both device and simulator), where one of the constraints in the list is something like this: "<...
Goodsquirrel's user avatar
  • 1,514
49 votes
9 answers
61k views

I'm trying to achieve the following: I have 2 views in my xib that need to stay 20 pixels off the edge (both sides and top) The 2 views that need to resize aren't the same size They have to be 20 ...
Simon Germain's user avatar
48 votes
3 answers
48k views

I want to modify the layout constraints when the device rotates. My UIViewController is composed of 2 UIViews, in landscape they are horizontally aligned, and in portrait they are vertically aligned. ...
vitaminwater's user avatar
  • 6,954
45 votes
8 answers
54k views

I have a View which has two labels and a Table View inside it. I want label 1 to always stay above my Table View and label 2, to be below the Table View. The problem is that the Table View needs to ...
Dumpen's user avatar
  • 1,672
38 votes
1 answer
52k views

I want to animate an object, so I declare a constraint and add it to the view. I then update the constant property of the constraint inside an UIView animation. Why doesn't this code move the object? ...
Cesare's user avatar
  • 9,455
36 votes
3 answers
23k views

I have a simple (I think) problem: I have a UIImageView, which I have set multiple constraints for in the storyboard. At times, I'll need to disable the constraints, and set its frame manually, but ...
Randoms's user avatar
  • 2,130
36 votes
4 answers
25k views

I am trying to place UITextView inside UIScrollView with AutoLayout with no luck. What I have tried is, I placed UIScrollView inside the main view in Storyboard I placed UITextView inside UIScrollView ...
Sodbileg Gansukh's user avatar
33 votes
5 answers
59k views

I have a question about setting the size of a view to which i'm applying some layout constraints. How can I define the size of the view without defining its frame? I'm trying to create a view that ...
Sean Danzeiser's user avatar
33 votes
4 answers
26k views

From time to time I have a subview that I would like to remove from a layout. Not only should it be hidden, but it should not be considered part of the view's 'flow', so to speak. An example: I am ...
Ben Packard's user avatar
  • 26.6k
32 votes
6 answers
27k views

I'm trying to build a titleView with constraints that looks like this: I know how I would do this with frames. I would calculate the width of the text, the width of the image, create a view with that ...
Bob Spryn's user avatar
  • 17.8k
32 votes
3 answers
28k views

I am trying to understand how one can utilize Auto Layout to position items relative to other views percentage-wise. For example, I recently learned that you can specify a view's bottom should lie 4% ...
Jordan H's user avatar
  • 56.5k
31 votes
2 answers
3k views

I frequently run into this problem where I want my views arranged in one manner for portrait and a somewhat drastically different manner for landscape. For a simplified example, consider the ...
nhgrif's user avatar
  • 62.2k
29 votes
3 answers
12k views

I've noticed that in iOS 10 Beta 5 (about to try Beta 6), AutoLayout constraint animation behaves a bit differently. For example, this approach does not work the same as it did in previous iOS ...
Ben Guild's user avatar
  • 5,206
29 votes
3 answers
64k views

I want to create a UILabel programmatically with height, width and then I want to add constraints to it also programmatically for positioning the UILabel. Update: I want to create UI like this: How ...
Varun Naharia's user avatar
29 votes
5 answers
30k views

Am new to Auto layout constraints in Xcode. I have one Bottom View like UITabBar with 6 UIButtons. Without constraints I aligned those buttons with 5 space padding with each buttons and each buttons ...
Yuvaraj.M's user avatar
  • 9,791
28 votes
3 answers
10k views

The new NSLayoutConstraint methods activateConstraints: and deactivateConstraints: don't appear to work correctly with IB-created constraints (they do work correctly for code-created constraints). I ...
rdelmar's user avatar
  • 104k
28 votes
1 answer
10k views

In the code below, these four methods are called for layout reasoning. I'm a little confused why all of them are needed, though, and what they do differently from one another. They're used in the ...
Doug Smith's user avatar
  • 29.5k
27 votes
1 answer
14k views

Is there a way to install and uninstall an Xcode interface builder constraint programmatically?
Eric's user avatar
  • 3,841
26 votes
4 answers
76k views

I'm experimenting with how to use UIScrollView. After much trouble, I finally got the hang of it. But now I've seem to hit another snag. In this simple app, I have a scroll view with and in order for ...
Isuru's user avatar
  • 31.4k
26 votes
3 answers
11k views

Interface Builder in XCode 4.5 respects the intrinsicContentSize for some views, e.g. NSButton, but I can't convince it to respect it on my own custom subviews. This causes IB to add extra constraints ...
bitmusher's user avatar
  • 887
25 votes
5 answers
23k views

I am running XCode 5 with iOS 7. I need to dynamically change the height constraint of a UITextView prior to its layout. I have seen many postings stating that this can be done by making an outlet ...
johnnyspo's user avatar
  • 629

1
2 3 4 5
43