FAQ Database Discussion Community


Obj-C, changing autolayout at runtime, woes

ios,objective-c,cocoa-touch,autolayout,ios7.1
I'm trying try hide table view and move a button up the screen, which is different to my autolayout setup. Basically, I have a free version of my app where I hide things, then if they purchase I need to set the constraints back to those in interface builder. I...

UIView doesn't size itself to superView

ios,objective-c,autolayout,nslayoutconstraint
I have a UIView with constraints like this: All vertical and horizontal spaces are set to 0. Then in viewDidLoad I added a view as the subview of the original UIView. Here is what it looks like: self.innerView = [[UIView all] initWithFrame:self.myView.frame]; [self.myView addSubview:self.innerView]; When I run the app, innerView...

Adjusting views when Status Bar hides on rotation

ios,rotation,autolayout,uistatusbar
I've browsed around looking for an answer for this, but I've only found people with similar problems and not this exact problem, so hopefully someone here can help me! I have an iPad App. On iPad, when you hold the iPad in either portrait or landscape, the status bar with...

How to center view with autolayout

ios,autolayout
I have universal app. Subview is rectangle which is positioned inside View. How can I keep it centered and make it automatically adopt it's width depends on screen width ? e.g. ...

Autolayout Constraints Breaking on Widths Equally

ios,autolayout
I am applying constraints using IB on few views just for learning purposes. The constraint "Width Equally" is applied on the red and blue view. But as soon as I apply it shows a yellow line for the autolayout constraint. Both views have width 258. Here is an image:

Programmatically using constraints to center a UIIMageView

ios,objective-c,uiimageview,autolayout,xib
I'm working on an iOS project in which I need to programmatically use constraints for my views. I'm used to storyboards, but am using xibs for this particular project due to the nature of the project specification. I have a MainViewController, in which I create the following properties in the...

AutoLayout for UICollectionView Cells

objective-c,iphone,resize,autolayout,uicollectionviewcell
I have an uicollectionview in my app which shows the photos from the camera roll (using AssetsLibrary) in small square cells by using an uiimageview. My problem is that it all looks fine on an iPhone5/5S but there is huge spacing between the cells when running it on an iPhone...

Autolayout, size classes and font size

ios,swift,autolayout,nslayoutconstraint
I'm currently working with the following : Swift (1.2), Xcode (6.3) and iOS 8.3. I currently have an application that look similar to this sample I've made for this question : For each UIButton / UILabel I would like to configure their font size depending on which device is used...

how can I make in auto layout that view1 height will be = 3.7 view2 height?

ios,autolayout
I have view1 and view2 on screen. how can I make in auto layout that view1 height will be = 3.7 view2 height? Maybe that can be done by adding constraints in code. But I want to know all solutions. Also how It can be done that view1 height will...

Can't change Constraint IBOutlet that is defined for different size classes in IB

ios,autolayout,interface-builder,nslayoutconstraint,size-classes
I made a special test app for this case. I added a view on my controller's view in Storyboard, set up AutoLayout constraints in Interface Builder and made one of them (vertical space) is defferent for different size classes. Screenshot from IB So the value is 100 for Any height,...

Mixing storyboard and constraints in code

ios,iphone,swift,cocoa-touch,autolayout
I'm trying to implement view controller from this wireframe As we have different screen resolutions - different number of yellow views can fit on the screen. All yellow views are same size UIImageViews, containing the same image. What I'm trying to do is to layout view controller in storyboard except...

How to set layout constraints for variable hight calculated at run time?

ios,xcode6,autolayout,size-classes
I have a UIView with 3 UIViews as its subviews. I have set layout constraints for these subview as fixed aspect ratio. i.e if the screen size changes their width will change but aspect ratio will always be the same. Now i have also made width of the UIView (the...

How to setup a view with a half of screen height?

ios,xcode,swift,autolayout
I want to set view1's height to half of the screen's height for all devices (when the device in the portrait mode) Here is what I want it to look like: so I make an auto layout of View1's height @IBOutlet weak var heighConstraint: NSLayoutConstraint! my viewwillappear function here: override...

Size-classes and constraints with buttons

ios,objective-c,autolayout,constraints,size-classes
I hope someone can help here as I've been reading and watching a lot about size classes as I've just started work on first app using size classes.I thought I'd got the idea but having a slight issue. I've got a view with 10 buttons in it. I want the...

ScrollView -> View (Label + Label + TableView) and autolayout

ios,objective-c,uiscrollview,autolayout,constraints
Inside the ScrollView are two Labels (multilateral), and below it the TableView (in which the number of rows may be different). The height of both Label and TableView is not set. All outlets set constraints on the indents from each other above and below, including a View of the container....

Resize images automatically in CollectionViewCell in CollectionView with Auto Layout

ios,swift,autolayout,uicollectionview
I have a collectionView with horizontal UICollectionViewFlowLayout. I am trying to achieve: If a device orientation is portrait, UIImageView width will be qual to view.width and let the height be calculated automatically (like it usually happens with Auto Layout). And the same for the landscape mode. Example - standard photo...

how can i get the height of UILabel?

ios,uiscrollview,autolayout
hello everyone, Here i took one UIView and UIScrollview from storyboard and set its constraint from storyboard and i have created one UILabel programmatically inside of UIView and set its constraint. Now my problem is how can i get the height of UILabel? so based on its height i want...

AutoLayout TableView issue with iPhone 6 and 6 Plus

ios,objective-c,autolayout
I have 7 labels on a cell in TableView in Landscape mode and I have set the Top Space and Leading Space on each. My issue is it is working fine with iPhone 5 screen it fit well but I get and empty space with iPhone 6 and 6 Plus...

UILabel autoshrink and use 2 lines if necessary

ios,objective-c,xcode,autolayout
I've got a UILabel that I would like to first shrink the text to fit a single line if possible. If that doesn't work I would like it to use at the most two lines. Is this possible? Currently with the settings I have it does this: Here is my...

iOS - Custom table cell not full width of UITableView

ios,objective-c,uitableview,autolayout
I may be going about this wrong. So I have created a UITableView that essentially has a auto-layout trailing space set to the main view. I am creating a custom cell for this table so I drug on a prototype cell, customized it, and created my class for it. That...

iOS UIView size

ios,objective-c,iphone,uitableview,autolayout
I have a Controller with 4UILabels that are constant height throught all the iPhones, below the lastUILabel there is aUIView with a page controller(with aTableView inside that page controller). What I want is that theUIView take all the height that he cant : example: Screen of 600 height 4UILABELS =...

Add constraint before view is seen?

ios,swift,autolayout,uikit,nslayoutconstraint
I am trying to center an arrow button with a width = 40 in the middle of my screen using constraints programmatically. My code works if I call it in viewDidAppear but crashes in viewDidLoad. Having it in viewDidAppear is an eye sore since you see the screen and then...

UITableViewCell conflicting height constraint

ios,swift,uitableview,autolayout
I have a custom tableview cell where I'm letting auto layout manage the height for it. tableView.estimatedRowHeight = 44 tableView.rowHeight = UITableViewAutomaticDimension Inside the tableview cell I have a container subview: contentView.addSubview(calendarEventContainerView) All the content I'm adding goes in the calendarEventContainerView and I would like the subview to be a...

Use AutoLayout to scale down UIImageView height

ios,objective-c,uiimageview,autolayout,uitextview
So, In my app I have an UIView (it resizes keeping the same aspect ratio so that it always touches the sides of the screen) and in that view I have an UIImageView and an UITextView on top of it. Visually (the pink rectangle is the textview): What I want...

iOS 7 - Layout advice

ios,objective-c,uiscrollview,autolayout,uicollectionview
I have the following layout in my view controller. I want to be able to scroll vertically with the header scrolling off the view and the UISegmentedControl sticking to the top of the view, beyond that the remaining scroll should be handled by the Collection View. However I'm a bit...

Dynamic Pictures Adding in table View

ios,swift,autolayout,xcode-6.2
I'm trying to do a bit tricky thing for me (new to the layout constraints thing). The idea is that I have to dynamically add pictures to a table cell.The cell structure is: an image view text view scroll view (horizontal scrolling) which contain images inside the images part &...

How to make Auto Layout for Universal App

ios,objective-c,autolayout,ios-autolayout
I'm now doing an universal app; I faced a problems on auto layout; I need to make two views with same size on all devices; I worked on storyboard with view wAny hAny; and here the images I reach The problem on iPad the bottom view it's very big and...

Layout still needs update after calling NSTableRowView layout

osx,swift,cocoa,autolayout,nstableview
I have two NSTableView's in my app and the user can drag and drop items from table A to table B. When dragging an item to table B Xcode gives me the following layout warning message: Layout still needs update after calling -[NSTableRowView layout]. NSTableRowView or one of its superclasses...

UICollectionView cell height/scrollable content behaving strange/incorrect

ios,ios8,autolayout,uicollectionview,uicollectionviewcell
I'm trying to make UICollectionView work like UITableView (I want the extra flexibility of collection view instead of just going with table view, both for some current and possible future feature extensions); having a fixed width (screen width) and dynamic cell height (just like iOS 8's new table view feature)....

making UILabels / UITextFields looks the same proportionally on all phones

ios,swift,autolayout
Using autolayout, what is the best way to make something like this look the same on all iPhone sizes? Adding constraints to all of the individual components has caused one of the UITextFields to be bigger than the rest every time, and I'm unsure how I could make them all...

Wrong width of custom section header form xib

ios,iphone,uitableview,autolayout,xib
I can't manage to make the view's width adapt to the size of the table view on different screen sizes Here's my code on viewDidLoad() view.tableView.registerNib(UINib(nibName: "Header", bundle: NSBundle.mainBundle()), forHeaderFooterViewReuseIdentifier: "Header") And on the Table View Delegate: func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { var cell = tableView.dequeueReusableHeaderFooterViewWithIdentifier("Header")...

How to make uiscrollview only vertical scrolling for ios?

ios,objective-c,ios8,uiscrollview,autolayout
I'm trying to make layout inside scrollview using this one tutorial https://www.youtube.com/watch?v=UnQsFlMGDsI And get the following result http://youtu.be/iPfzyLbEZMA It will be appreciated for any advices or tutorial links. It needs only vertical scrolling...

iOS AutoLayout Problems - Subviews Misplaced Even Though No Constraints

ios,objective-c,iphone,autolayout,constraints
I have a project where some of my views use constraints and some of them don't really need to because they show up nicely on other device sizes as well. My problem is that when I deleted all my constraints in a view controller's subviews, The subviews get heavily misplaced...

When I add autolayout, the views disapear

ios,objective-c,autolayout,nslayoutconstraint
I have 1 label and 1 UICollectionView in an overall view. I'm trying to get them like the image below: I can't use the storyboard to apply auto-layout, I have to do it programmatically, and I'm having difficulty doing that. Here is what I have: CGRect collectionViewFrame = CGRectMake(0, 20,...

auto layout modify multiplier of constriaint programmatically

ios,objective-c,autolayout,constraints
How can I modify the multiplier of a constraint programmatically? I have set the following: [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_button attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth multiplier:0.5 constant:0.0]]; and I need to modify it to this: [self.view addConstraint:[NSLayoutConstraint constraintWithItem:_button attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth...

Adaptive layout for iPad

ios,swift,ipad,autolayout,size-classes
I am following this article for building adaptive layout in ios Building Adaptive User Interfaces for iOS 8. It will work fine on iPhones . Now i wan't to give the same effect on iPad. But for iPad adaptive layout is not work. Here is screenshot of application in iPhone5...

Issue with constraints

ios,objective-c,autolayout,nslayoutconstraint
I have a UILabel and a UITextField that I created, and added constraint programmatically. Here is the code I inserted in viewDidLoad: UILabel *currencyLabel = [[UILabel alloc] init]; UITextField dollars = [[UITextField alloc] init]; CGRect label = CGRectMake(0, 0, 12, 33); currencyLabel.frame = label; CGRect textField = CGRectMake(12, 0, self.amountView.frame.size.width...

programmatically scroll to a specific page/position with autolayout iOS

ios,cocoa-touch,uiscrollview,autolayout
I am using autolayout with a scroll view. It is working great, but I need to be able to scroll to specific pages programmatically. Specifically, I need to scroll to the last page after the view loads. How do I do this? My scrolling essentially has the visual format shown...

How to remove space of hidden UIImage?

ios,uiimageview,autolayout
I'm stuck that I don't know how to remove spacing of hidden UIImage. Purpose is If flag is true, UIImage will be displayed and if flag is false, UIImage is hidden but space of this hidden image is still there. I'm using Auto Layout. ...

How to add auto layout on UICollectionView programmatically?

ios,objective-c,autolayout,uicollectionview
I create a uicollectionview programmatically, and I want to add auto layout constraint on the collection view so that I can change the frame later. But the following code is not work. I am trying to initialize the collectionview like this: self.rootCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 100, self.bounds.size.width, self.bounds.size.height - 100)...

Align two labels vertically with different font size

ios,autolayout,uilabel,vertical-alignment,baseline
I have a parent UIView where I place two labels on it. Each of these labels only has one line as can be seen here: The problem now is that the baseline is wrong. I'm using auto layout and the question is how should my constraints should look like in...

UITableViewCell Can Not Constrain Label to Right Edge

ios,swift,uitableview,autolayout,interface-builder
I have subclassed UITableViewCell (with a xib), and I have noticed that when I use autolayout/constraints, the labels that I place in Interface Builder do not show correctly at runtime. First, I put three labels aligned left, center, and right with respect to the cell's content view. When I run...

UITextView inside UICollectionViewCell insists on growing horizontally

ios,ios8,autolayout,uicollectionview,uicollectionviewcell
I have a UITextView inside my UICollectionView cell, and it keeps getting growing horizontally depending on its content. My collection view is set to be vertically scrolling, and the cells calculate their own size. I want my text view to grow vertically depending on its contents, not horizontally. Here is...

animating a view on top of uitableview

ios,swift,autolayout
I have a UINavigationController that has my custom ViewController with a tableView in it that takes up the whole screen. I want to push down the tableView and reveal a settings menu with just a couple items. My SettingsView.xib I created in a separate nib that is 320 x 90...

UIToolbar with UISegmentedControl AutoLayout (/full width)

ios,objective-c,autolayout,uisegmentedcontrol,uitoolbar
I have a UIViewController with a UIToolBar below the UINavigationBar and a UITableView below that. The only UIBarButtonItem on my UIToolBar is a UISegmentedControl as in the screenshot below: However, how do I get the UISegmentedControl/UIBarButtonItem to stretch to fill the UIToolBar like in the App Store app? Keep in...

Alignment of buttons in view

xcode,autolayout
I have 4 buttons in an row, how can i align this in the middle on each device? iphone 4s, iphone 5s, iphone 6, iphone 6 plus. Only on the iphone 6 it looks good. On the iphone 4s the buttons going outside the view and on the 5s and...

Decrease amount of space between elements when space is restricted

ios,autolayout,nslayoutconstraint
Imagine the case where you have three buttons side by side. You want the three buttons to fill the available width, and be perfect squares with a minimum size set, with a set amount of space between them. To set this up, you would have the following constraints: A: 1:1...

Objective C: Adding UI button with constraints programatically

ios,objective-c,uibutton,autolayout
I want to create button of fixed dimension which is set to fix distance from top right regardless of screen size and orientation, But not able to achieve it. I have tried following code which shows correctly in portrait mode only since frame location is fixed. self.closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];...

iOS - Autolayout - Increase/Decrease view size proportionally on orientation change

ios,xcode6,autolayout
I went through ray wenderlich's tutorial about autolayouts (link) and then began working on a demo project thinking I've figured it all out but I was wrong. As shown in the screenshot below I have a navigation bar, 2 views and 1 button. The layout on portrait mode looks fine...

AutoLayout complains about constraints for 2 UITextFields with no borders

ios,xcode,swift,autolayout,nslayoutconstraint
I am trying to build my login view that has only 2 TextFields, and 2 buttons. I am applying the "Add Missing Constraints" property so that Xcode applies the corresponding constraints to all the elements in my LoginViewController in the storyboard. I am restricting my app to run only in...

Fit a UIImageView to a UIImage

ios,objective-c,uiimageview,autolayout
I have a UIImage View that is set up using AutoLayout and constraints. I fit the image to the Image View using self.selectPhoto.contentMode = UIViewContentModeScaleAspectFit; NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:self.topLayoutGuide attribute:NSLayoutAttributeBottom relatedBy:0 toItem:self.selectPhoto attribute:NSLayoutAttributeTop multiplier:1 constant:-10]; NSLayoutConstraint *bottomConstraint = [NSLayoutConstraint constraintWithItem:self.selectPhoto attribute:NSLayoutAttributeBottom relatedBy:0...

How can I achieve a 30 button grid using autolayout storyboards?

ios,xcode,autolayout,xcode-storyboard
So I had this working for a 12 button (4x3) grid of buttons. I'd like all of the buttons to be equal size, common distances above and to the side of each other, and the entire grid to be centered on the device, like so: The problem is, it looks...

Getting error when adding constraint

ios,objective-c,autolayout,uikit,nslayoutconstraint
I'm trying to set a constraint on 2 views so that they touch each other like this: I tried setting constraints programmatically: [self addConstraint:[NSLayoutConstraint constraintsWithVisualFormat:@"[_firstView][_secondView]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_firstView, _secondView)]]; But I get the following warning: Incompatible pointer types sending 'NSArray *' to parameter of type 'NSLayoutConstraint' What am I doing...

change Auto Layout dynamically

ios,iphone,xcode,storyboard,autolayout
I have to show 3 Labels like LABEL1 | LABEL2 | Label3 //Horizontally I want these 3labels width are equally divided according to Screen size width How can I achieve this with nib file directly? Thanks Question 2 Label1 | Label2 | Lable3 //All Labels widths are equally //All Labels...

ScrollView with Tab bar

ios,autolayout
I have a to implement something similar to a chat. So I thought I will add a scrollview then a table view then a view for textfield and send button then on top of it a tableview. I also have a tabbar on bottom Is this the right approach. I...

Can the height of the UISearchbar TextField be modified?

swift,autolayout,uisearchbar
I'm testing out my UI and I find the search bar a little bit too narrow for my liking. I also want to make sure people with poorer vision or poorer manual dexterity have no issues bringing up the interface they want. So, what I would like to do is...

How to add custom UIView(xib) in custom UITableviewCell with the help of AutoLayout?

ios,objective-c,uitableview,uiview,autolayout
I have one View Controller in which I have one UITableView. I have used custom UITableviewCell with xib in that UITableView. Now I have one UIView with xib and I want to add that UIView's object in custom UITableViewCell with the help of AutoLayout. I added that UIView successfully in...

Center Align UIImageview and Large UILabel AutoLayout

ios,autolayout
I have a UIImageView and a UILabel. Label has greater height than image, so I want to center align Y position for both. Here is original case: When I apply Center Y from image to label, label content is truncated. Please can someone guide me for correct constraints... Thanks!...

Where are constraints updated for size classes?

ios,iphone,autolayout
I have a constraint in interface builder with a default value and a compact width value. I have this constraint linked to an IBOutlet so I can get the constant value in code at runtime. If I run on an iPhone 4S simulator, in viewDidLoad the constant is the default...

Load custom view from .xib doesn't fit to iPhone 6+

ios,iphone,uiview,autolayout
I m using Autolayout in my app. When I load my custom UIView from .xib from viewDidLoad it's size is (300,325) like it should be, but on iPhone6+ is't actually (394, 493). But when I load my custom UIView from .xib after that (somewhere) the size isn't change ( stay...

AutoLayout constraints to UITableViewCell contentView not respected

ios,uitableview,autolayout,uilabel
I'm trying to create dynamically resizing table view cells. I accomplished the resizing by using this answer, which is very detailed and helpful. However, the maximum width for the label is not being calculated correctly inheightForRowAtIndexPath. My cell currently only has one label in itscontentView, with constraints set to pin...

TableView Header AutoLayout

ios,uitableview,autolayout,uistoryboard
Trying to get my Table View header to resize dynamically based off of three labels, one of which has dynamic content. Seems quite simple enough, but not having much luck. Any suggestions greatly appreciated! Following this post here, have setup my constraints as such: And my code is quite simple....

Autolayout works great on iOS 8, crashes on iOS 7

ios,ios7,ios8,autolayout
I have an issue where a screen with autolayout that works great on iOS 8 - but crashes on iOS 7. All subviews are configured in the XIB. The error message is: Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to install constraint on view. Does the constraint reference...

iOS Autolayout view height based on larger subview height

ios,swift,autolayout,interface-builder
So I have a view in interface builder and I want its height to be based on the larger (height-wise) of the two subviews inside of it. However, that will only be determined when the view is loaded and the content is filled in via viewDidLoad. So right now I...

Choosing maximum of two widths for auto layout

ios,autolayout
I have a UIImageView and two two UILabel as its child. Now using auto layouts I want that UIImageView's width should be equal to the maximum of these two labels so that both of these are visible completely. Is there a way to define this constraint?

Can UIStackView also be used within a UITableViewCell?

ios,uitableview,autolayout,ios9,uistackview
Can UIStackView be used to resize, reposition, or collapse views within a UITableViewCell?

I get some layout constraints error in iOS

ios,iphone,autolayout
I get some error log infoļ¼ŒBut the position is not the position code, can you help me to point out the cause of the problem Below is the details of the crash log, I can't find more position the code, what's the problem. detail crash log: The layout constraints still...

UITextView not resizing correctly on iPad only

ios,objective-c,ipad,autolayout,uitextview
I have a static UITableView with 3 rows in 1 section. Each row contains a UITextView that should resize based on the content. Each of the UITextView objects has scrolling disabled to force it to grow. Each is pinned on all 4 sides to the cell's contentView and has no...

Moving a textfield with auto layout constraints when the keyboard appears

ios,swift,autolayout,constraints
I have a search bar text field and a table view (for google auto complete) that I would like to translate up when the keyboard comes into view. I am successfully doing this, however, I am getting warnings/errors about my constraints. I am using auto layout via storyboard on this...

'+=' cannot be applied to two [AnyObject] operands

xcode,swift,autolayout
I have the following code to try and create an array of constraints to add to a view: let views = ["button": button] let metrics = ["margin": 16] var constraints: [AnyObject] = [] constraints += NSLayoutConstraint.constraintsWithVisualFormat("|-margin-[button]-margin-|", options: 0, metrics: metrics, views: views) From what I understand about Swift arrays, I...

Swift visual delay in text height change

ios,swift,view,autolayout
I have a main display with a button, and when that button is clicked, it transitions to a second screen. In that second screen, I have a text label with a colored background that changes depending on the size of the screen using auto layout / constraints. I am then...

IOS Scrollable View inside another ScrollView

uitableview,swift,autolayout,uicollectionview,ios8.3
I need to implement this screen and I wonder if anyone can help me with ideas to solve some scenarios, basically the screen will contain a parallax effect in the top image, the entire screen must be scrollable, the problem I am faced when designing this screen It is the...

Animate image view inside a container view in iOS?

ios,objective-c,autolayout,nsautolayout,ios-autolayout
I'm trying to animate a image view inside a container view. Container view is square and aligned center of the screen. i do have a image view inside my container. position of my image view is shown in below screenshot.(super view is my container view) i want to animate the...

Why am I getting three dots in Auto Layout?

xcode,autolayout
I tried doing auto layout but I keep on getting three dots. How do I fix this? Screen shot of how it looks below. ...

Label on UIButton not laid out correctly with autolayout

ios8,uibutton,autolayout,uikit,uistoryboard
I have an app which I'm updating to auto layout and size classes and I'm getting some weird behaviour with the label on a button. The button should be a circle and have a label in the centre. I'm implementing my own subclass so I can reuse it. Here's the...

Autolayout in code ? height issue?

ios,autolayout
I have Two View say view1 and view2. - view2 should be at 2 pixel distance from view1 (vertically) and - Height of view2 should be such that bottom of view2 must be same as bottom of viewcontroller. How to specify the constraint for this in code ? ...

Views width fails to change properly with auto-layout

ios,objective-c,autolayout,nslayoutconstraint
I have 4 UIButtons in a static cell with width constraints and regular constraints on all 4 sides. At a certain point, I want to change the constraints width. Here is my code: - (void)viewDidLoad { [super viewDidLoad]; self.constraintArray = [[NSArray alloc] initWithObjects:self.budgetWidthConstraint, self.categorieWidthConstraint, self.extraButtonWidthConstraint, nil]; } - (void)myLayout {...

UIView respect uinavigationbar size storyboard

ios,objective-c,uiview,storyboard,autolayout
I have this UIView, wich is supposed to be fullscreen, but in my uiviewcontroller, i have an uinavigation bar. If i put the UIView inside it, with the same size as the uiviewcontroller view, it ignores the 64px of the navigationbar, making it bigger than the screen. Theres any way...

IOS - Adjust cell height based on content

ios,uitableview,autolayout
im trying to build apps that have tableview cell similiar with twitter, there are text and images. My problem is i want to insert the image above the text. While it can be text only. So if there are no image, the text will be in position (0,0). And if...

iOS iPhone 6 Autolayout - Full Width and Height

ios,objective-c,storyboard,autolayout
I designed my app to work on iPhone 5 and now want to make it compatible with iPhone 6 screens. When I change the simulated metrics size to iphone 5.5 inch in the storyboard, I see that my view is no longer the full width and height of the screen....

Using auto layout to arrange views in sequence with one taking whatever space is available

ios,swift,autolayout
I'm trying to arrange 5 views horizontally and currently my visual format and view properties (colors omitted) look like this: let questionLabel = UILabel() questionLabel.text = "Did you take any additional medication?" questionLabel.lineBreakMode = .ByWordWrapping questionLabel.numberOfLines = 0 let questionSwitch = UISwitch() let noLabel = UILabel() noLabel.text = "No" let...

Sibling object not available in menu when setting Auto Layout constraint in Storyboard

ios,xcode,storyboard,autolayout,interface-builder
The Apple guide "Adding Auto Layout Constraints with the Pin and Align Tools" states: To create a constraint related to another item that is not the nearest neighbor, click the black down arrow in the text field and choose another nearby item from the pop-up menu. https://developer.apple.com/library/ios/recipes/xcode_help-IB_auto_layout/chapters/pin-constraints.html My Storyboard has...

When do you need content hugging for labels and buttons to prevent them from taking the space of a text field?

ios,autolayout,visual-format-language
I am puzzled with a simple layout created programmatically, where you have a UILabel, a UITextField and a UIButton in a row using constraints. I hope you can help me understand the following behaviour. If I use visual format language to lay out those views like this... |-[label]-[field]-[button]-| ...I see...

Why does an orientation change AutoLayout for my UITableViewCell?

ios,uitableview,cocoa-touch,autolayout,orientation-changes
I am trying to use AutoLayout inside a UITableViewCell with Objective-C. I am not using a nib/xib/storyboard. I create my views in code. Here's my UITableViewCell: @implementation SettlementTableViewCell - (instancetype) initWithReuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]; if (!self) return nil; [self setSelectionStyle:UITableViewCellSelectionStyleNone]; _order = [[UILabel alloc] init]; [_order...

Move UIView when Keyboard appears with AutoLayout

ios,objective-c,autolayout,uikeyboard
I got an UIView which I'd like to move up/down whether the UIKeyboard appears or disappears. Unfortunately I can't get it to work. Prior to AutoLayout it was a no-brainer but since AutoLayout I have some trouble with this one. Here is what I have so far: - (void)viewDidLoad {...

Autolayout dynamic height table view cells render wrongly when text changes

ios,objective-c,uitableview,autolayout
I have a a custom UITableViewCell using Autolayout and iOS8 Dynamic Height, containing two labels of different size. The upper label could be anywhere from 1 to 2 lines, and the bottom label is always only 1 line. In :cellForRowAtIndexPath: I set the text of the upper label to "Loading.."...

iOS 8 Autolayout - Visual Format Language how to add constraint to superview's edge

ios,swift,ios8,autolayout,nslayoutconstraint
Can I pin my view to my superView's edge instead of its layout margin through VFL? Can I be even flexible to toggle "Relative to margin" on myView as well? NO VFL (this is what I want to achieve with Visual Format Language): var constraintLeft = NSLayoutConstraint(item: myView, attribute: NSLayoutAttribute.Left,...

Prevent Interface Builder from auto creating Constraints?

ios,autolayout,interface-builder,nslayoutconstraint,xcode-storyboard
I created a demo project here. I have a view where I created a ScrollView in a .xib file. In interface builder I did not set any constraints. In my viewDidLoad method I set constraints with SnapKit: scrollView.snp_makeConstraints { (make) -> Void in make.edges.equalTo(self.view) } When I run the code...

What does this auto layout error mean?

ios7,ios8,autolayout
I recently was trying to making my IOS 8 app built, with swift, become compatible with IOS 7 devices, but I've been running into some minor issues. I've fixed most of them, but I can't seem to find this error on the web or anything close to it. Can anyone...

error when adding constraints to a view I added to UIWindow?

objective-c,autolayout,uiwindow,addsubview
I'm sorry my english is poor. My code like below: two views will be added to the window UIWindow *window = [[[UIApplication sharedApplication] delegate] window]; if (!_transparentView) { _transparentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_BOUNDS.size.width, SCREEN_BOUNDS.size.height)]; [_transparentView setBackgroundColor:[UIColor blackColor]]; [_transparentView setAlpha:0.5]; [window addSubview:_transparentView]; } [_transparentView setHidden:NO]; _noSupportairDropTipView = [[[NSBundle mainBundle]...

Xcode 6 iAd Layout Issue or Bug

autolayout,iad
I have added an iAd banner view to my project and pinned it to the top of the main view controller in a storyboard. Initially when the app loads the iAd banner is displayed at the bottom of the screen. The banner is then hidden during a game and then...

Container View's Frame Set to CGRectZero when Using Programmatic Auto Layout

ios,objective-c,uiview,uiviewcontroller,autolayout
I have a UIView subclass that will be a tooltip that can appear on the bottom of any view controller to show a hint/error message/success message/etc. The tooltip view has two subviews: a UILabel on the left-hand side and a UIView on the right hand side, that can be anything...

Getting Autolayout beneath the status bar

ios,cocoa,format,autolayout
I have read multiple previous posts on Autolayout and the status bar behavior in iOS 7 and still do not know how to get my Autolay-ed out objects to be beneath the status bar. I currently have self.automaticallyAdjustsScrollViewInsets = YES; self.edgesForExtendedLayout = UIRectEdgeNone; and a search bar has a visual...

Implementing an uiview subclass with children views using autolayout programmatically

ios,objective-c,uiview,autolayout,nslayoutconstraint
My need is very generic, I have to implement an UIView subclass which groups an UIImageView, x-centered on the screen and distant 20 pts from top, and a UILabel with a description. I have no problems doing it with interface builder, but since I needed to make it programmatically I...

Activity indicator not centered in landscape mode

ios,objective-c,xcode,autolayout,uiactivityindicatorview
I am trying to add an activity indicator on top of my table view such that it is appearing in the center of the screen in both portrait and landscape mode. The activity indicator is placed inside a view which is a subview of the main view. The table view...

Adding subview to cell dynamically is causing layout constraint error output

ios,dynamic,autolayout
I have a table cell view that consists of a couple of buttons and some details. The details are hidden until one of the buttons is touched, and removed when the other button is touched. I am using auto layout. Here is the code for adding the controls and configuring...

IOS8 Autolayout with relative width / height

ios8,storyboard,autolayout,constraints,orientation
I need to autolayout a storyboard UIView with a single UIControl. The UIControl should be centered, needs to have a aspect ratio of 1:1 and should always use 90% of the superviews width or height depending on the device orientation without clipping. I added 4 constraints Center Y Alignment -...

Swift: Animating Constraints on UIImageView

ios,swift,animation,autolayout
There are several answered questions out there similar if not the same as mine, however, none of them seem to solve my dilemma. I have an UIImageView that I move across the screen with the UILongPressGesture that I move by changing the horizontal and vertical constraints. If this image does...

strange behaviour with UINavigationController and autolayout top layout guide

ios,layout,uiscrollview,uinavigationcontroller,autolayout
I am using auto layout for a controller under navigation controller. For this controller, I mainly have a scroll view inside the controller's view. the alignment rule for the scroll view is top layout guide, bottom layout guide, leading aligned with super view and trailing as well. the layout is...

When to use Multiplier in iOS AutoLayout?

ios,objective-c,xcode,swift,autolayout
An autolayout constraint can be definded as: self.view.addConstraint(NSLayoutConstraint(item: label, attribute: .Bottom, relatedBy: .Equal, toItem: self.view, attribute: .Bottom, multiplier: 1, constant: 0)) I did not understand what a use case would be for using the multiplier. When to use Multiplier in iOS AutoLayout?...