Questions tagged [autolayout]

-3

votes
2

answer
135

Views

Why does my empty iOS single view app project crash?

I created a new iOS project based off of Xcode's Single View iOS app template and was very surprised to find that adding a label and 4 basic constraints for the top, right, bottom, left position results in an immediate launch crash. There is literally nothing else in the project, it is empty, I'm c...
Josue Espinosa
-2

votes
1

answer
12

Views

Stack Views in Storyboard (Swift)

I'm working on this tic tac toe game, and I set adaptive constraints in a storyboard. So far I don't see any errors in Xcode panel, but when I run it looks good in all devices except iPhone SE, so I'm trying to figure out what to do? iPhone XS max iPhone SE As you can see above in iPhone SE [ O ] l...
Harshil Patel
1

votes
1

answer
2k

Views

UITableViewCell: unable to simultaneously satisfy constraints

I've got a UITableViewCell that I'm creating, and I am using auto layout with constraints constructed entirely in code. While the actual output in the app is fine (i.e., it looks just as I have designed it to look), I am getting the famous 'Unable to simultaneously satisfy constraints' error/warning...
mbm29414
1

votes
2

answer
43

Views

Change textfield height on other devices

I'm currently working on an iOS application and I'm stuck.. I'm trying to create a 'register-form' and I'm designing using 'iPhone SE' (Cuz it seems like everyone else is doing so?) And when I'm designing on this device everything seems fine, but when I run the application the textfields seems to be...
Putte
0

votes
0

answer
27

Views

iOS - ambiguous layout

So i am trying lo locate a UIlabel in 2 conditions: 1.portrait 2.landscape As far as i know i am doing as i should with vary for traits. i can see the label in the storyboard located as i wanted: yet in the iphone it doesn't appears in the landscape mode: in the debugview tool i can see on the labe...
ironRoei
1

votes
0

answer
9

Views

Animate self-sizing NSTableView row height

I have a project that uses self-sizing table view cells. I'd like to animate when the height of a cell changes. NSTableView's noteHeightOfRows(withIndexesChanged:) will do this for view-based cells, but only when providing the height explicitly in the delegate's tableView(_, heightOfRow:) method. Wh...
smr
1

votes
2

answer
608

Views

UIScrollView Subviews not expanding to fill width (Autolayout)

I'm using the following code to constrain a view to the left and right anchors of a parent UIScrollView. Despite the right anchor and the left anchor being set to the ScrollView's left and right anchors, the view does not expand to fill the scrollview. Note: The gray background in this image is the...
orion
1

votes
2

answer
95

Views

How to resize label proportional to its superview

I have a view which contains a label (one line label). The label its centered horizontally in the top part of the view (20 from the top). When this view is resized (for example for iPhone 5 screen) I want my label to resize as well. The label font has size of 55, when the view is resized the font...
Adrian
1

votes
3

answer
157

Views

AutoLayout on Xcode7

I am having a lot of trouble understanding the Autolayout and how it is working phenomenally for everyone else but me. The problem is, the constraints when they end up working for me for one resolution e.g. for iPad, fail to comply with another like iPhone4s or something, and consequently either thi...
Mohsin Khubaib Ahmed
1

votes
3

answer
67

Views

Issues with AutoLayout

The Bar at the top is a view in a view that contains 10 views, each the same size however I am unable to get them to look like this on the simulator. What constraints settings should I be using? Also is there a better way to have visually represent all of these boxes without using views? it can't be...
Jams
1

votes
1

answer
86

Views

NSLayout Constraints failing

So i'm trying to programatically add constraints to my view using the following code. I'm trying to add some top space of 32 and some leading space of 16 to a view which is being added programatically to one of my view controllers but i seems to be running into some issues. Below is the example of...
Tunds
1

votes
2

answer
371

Views

How to use autolayout to make a dial pad in iOS?

The requirements are: Buttons that number from 0 to 9 Buttons should be evenly spaced from each other, and fit any screen size
NYC Tech Engineer
1

votes
2

answer
721

Views

Is there a javascript or web development library equivalent of ios' auto layout constraints concept?

Has anyone seen this done outside of ios development? The auto layout constraint concept is very interesting and could be helpful in responsive web design, possibly? What do you think/any equivalents out there?
lookingforsome
1

votes
1

answer
50

Views

Horizontal auto-layout constraint

In a subclass of UITableViewCell, I am trying to use auto layout. Here is what I want to do : Here is my code which doesn't work : only one view is shown import Foundation class CustomCell: UITableViewCell { func configureCell() { backgroundColor = UIColor.yellowColor() let redColorView = UIView() r...
Max
1

votes
2

answer
303

Views

Can I pin a label inside another label to create a border?

In an effort to create a border effect, I would like to pin one label inside another with, say, the following constants: up - 5 left - 5 right - 5 down - 5 This would give me a 5-point border around the inside label. Is this possible? If so, how do I make this happen? Or is there a better way to cr...
Michael Sheaver
1

votes
2

answer
133

Views

UIView cropped off even though constraints are set

I've created a custom view in a xib file, in which I've set all simulated Metrics to 'Inferred' In my view I float one stack view x to the left by pinning the left and the top side and stack view to the right by pinning the right and top. Somehow like this (the = sign symbolizes the screen borders)...
productioncoder
1

votes
1

answer
232

Views

Xcode Autolayout: Label centered between two neighbors [duplicate]

This question already has an answer here: iOS autolayout to center my view between two views 4 answers I have a Table View with a Prototype Cell. In it I have three labels: 'aaaa', '-' and 'bbbb'. '-' is Horizontally Centered in Container and I would like to place the 'aaaa' label centered between...
Victor Rius
1

votes
1

answer
338

Views

UIToolbar doesn't fit the screen

I made a a custom keyboard toolBar: To do that I created a toolbar let keyboardToolbar = UIToolbar(frame: CGRectMake(0, 0, self.view.bounds.size.width, 44)) and a view for the banner adToolbar = GADBannerView(frame: CGRectMake(0, 44, self.view.bounds.size.width, 44)) then I grouped them in another U...
Matte.Car
1

votes
2

answer
238

Views

iOS Autolayout constraint between non-siblings

Is there a way to define a horizontal distance constraint between two views which are not siblings? I tried to add a constraint to their first common superview but the constraint doesn't seem to work. The Apple documentation says: The constraint may only reference the view itself or its subviews. Bu...
frangulyan
1

votes
3

answer
72

Views

Main view taking top space from scrollview?

I have made a ui in which i am showing some textfileds.I have added all textfields inside a mainview & added mainview under scrollview.But main view is always taking space from top.I have added self.automaticallyAdjustsScrollViewInsets = NO; in scroll view .But that make scroll view static. Then th...
Dhiraj Kumar
1

votes
1

answer
230

Views

Change size of uiview with auto layout and make it always in centered

I have uiview with constraints for vertical centring inside superview and for width and height. On rotation of device uiview should always be in center, but I need to have ability to change width of uiview but its position should not be changed. I have tried: - to add leading and trailing constraint...
Dimitrio
1

votes
3

answer
641

Views

iOS - Displaying multiple labels inline

I was wondering if anyone could give me some insight on displaying multiple labels inline on a UITableView header. I understand this can be done through Autolayout or programatic layout.
xxyyzz
1

votes
1

answer
472

Views

Debugging a strange crash - NSInternalInconsistencyException

I'm having a strange crash with my application (only with iPad's 9.x) and I'm unsure how I can debug it, because the logs are not helping to discover what is happening. The strangest thing is that the log shows Auto layout internal error, but my application does not have Auto Layout turned on. Anyon...
Luciano Nascimento
1

votes
1

answer
78

Views

XCode 7.2 — How to accomplish the layout below using Auto Layout

Trying to accomplish the layout below using Auto Layout and settings constraints. The layout itself is comprised of four UIViews (top and bottom ones occupying the full width of the screen, the two middle ones side by side each taking half the width). However, after many tutorials on Auto Layout and...
fuzzlog
1

votes
1

answer
790

Views

Apple's 44x44 touch size minimum; smaller height and longer width acceptable?

So I just submitted my first app. The design elements (text fields) I am concerned about are 30x90. Should I have a problem with apple's minimum button size request?
jonpeter
1

votes
1

answer
457

Views

UILabel constraints in UITableViewCell change in landscape

I've got a static UITableView in my storyboard that has a combination of system cells and custom cells. In order to make the custom cells look like the system cells, I've added a 15 point constraint from the front of the UILabel to the cell's contentView (to match the default separator inset of 15 p...
Mark
1

votes
1

answer
73

Views

IOS AutoLayout with constraint exception when switching between landscape and portrait

I have different size classes for iPhone 6+ landscape and portrait. I don't get any constraint error if i run starting from landscape or portrait. The moment i switch from landscape or portrait, i get constraint errors. It seems that if i switch i get a merge of both portrait and landscape's size cl...
Hoay Min Yap
1

votes
2

answer
1.5k

Views

text in label bleeding off screen iOS Swift

I'm added in two labels into a table cell, the top one being left justified and the bottom being right justified, however the text isn't displaying properly. I added the proper constraints for the tableview in storyboard but that hasn't resolved the issue. Here is the code i used to set up the labe...
hnaderi
1

votes
1

answer
320

Views

Adding Subview to UICollectionViewCell Subclass?

I seem to be having trouble adding a subview to a view within my UICollectionViewCell subclass. I have an abstract UICollectionViewCell subclass titled MessageItem, which looks like this: I've created a few classes that inherit from this (since they all use the same logic for the header and footer)....
KingPolygon
1

votes
1

answer
693

Views

How can I turn Cocoa Auto Layout off for subviews of a NSView programmatically?

I have looked at the other similar questions, but none of them addressed the question of truly programmatically bypassing Auto Layout for subviews of a NSView. I would need to tell Auto Layout not to layout subviews of a particular NSView. I've tried overriding layout(), but this only generates a wa...
Melodius
1

votes
1

answer
561

Views

Auto RTL, LTR constraints behavior

Leading and Trailing constrains behaives depending on device langauge direction. To create an app that only support english requires to select every trailing/leading constraint and disable the respect language direction features. that converts the constraints to left/right constraints. I remember th...
hasan
1

votes
1

answer
1.1k

Views

How can I get the size of a view's margin?

I have a UIViewController, and I want to update another view within the controller so that the leading space is a certain distance from the left margin. My question is how do I get the size of the margin or how do I position something with respect to the margin?
App Face
1

votes
3

answer
150

Views

UITableViewCell Constraints

So I've been trying to make a custom layout of a UITableViewCell that it contains an image and label, as you can see it in the picture below. The main problem is the compression and hugging I haven't put my finger on it and I can't understand why the image expands, I have changed the compression and...
Cesar Mtz
1

votes
1

answer
1.3k

Views

Why isn't my mapview using the constraints to be full screen?

This is currently what I'm working with. I have repeatedly set the constraints to 0, 0, 0, 0 and with constrain to margins unchecked. However, ever time I run the simulator it's not filling the screen but remaining at 600x600. I have height and width unchecked so the only constraints I have added ar...
ggworean
1

votes
1

answer
1.8k

Views

AutoLayout for Container View inside parent View not aligned to layout guides

I'm really not sure how to put this question into words, so I'll present some incredibly partial screenshots of how the view in question looks. I'd provide more information, but I'm not sure if that'd be in breach of contract. Sorry! I have this setup for a Container View (itself inside a navigation...
Crow
1

votes
2

answer
456

Views

Autolayout constant for Equal width constraint setting to negative value

I have designed a simple view with some text fields, label and button, For my text field i have added a Equal Width Constraint for wC and h Any. But my xCode is showing up orange asking it to set to -60 value for constant, Can someone please help understand what does the negative value infer to and...
Max
1

votes
1

answer
280

Views

NSLayoutAnchor and constraint identifier

If I were to use NSLayoutConstraint, I would first initialize the constraint, lets say: let myConstraint = NSLayoutConstraint(...) Then I would add the identifier like that: myConstraint.identifier = 'myIdentifier' Then I would activate: myConstraint.active = true Is there a way to add an iden...
TheoK
1

votes
4

answer
347

Views

How do I use autolayout to align these two UIButtons?

I have a custom UIView XIB file, in which I have placed two buttons: Image of Buttons Here How can I progammatically (Swift) or using the interface align these buttons to look like this? Currently, I get this Current Buttons (BAD) Following Alexander's method, i did this, this is my current constrai...
Ronak Shah
1

votes
2

answer
129

Views

Achieve a percentage overlap with Autolayout constraints

Let Say View1 and View2 are two rectangles with the same size. With auto layout I can set View1.Center X = View2.Leading to make View1 and View2 overlap halfway in the X direction. Now I need this overlap to be a different percentage, let say overlap 1:3 or any other fraction. How can I achieve this...
Dogahe
1

votes
1

answer
778

Views

Update constraints programmatically when keyboard appears

To assure that textfields in a tabular view are always visible with a keyboard enabled, I want to shift the tableview upwards in case it would cover the controls. I have problems to do this in combination with autolayout applied programmatically. The constraints for the tableview are defined as fol...
Gerard

View additional questions