Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 8 Xcode 6: What's the point of the grayed out constraints?

In the Xcode 6 betas, when I delete a constraint, it doesn't remove it completely, but grays it out. I thought that was to imply that the constraint was used in a different size class, but that doesn't seem to be the case. Also, how do you permanently delete these constraints?

like image 389
RyJ Avatar asked Sep 02 '14 22:09

RyJ


People also ask

What does the greyed out constraint in a document outline mean IOS?

That's because of size classes, you can disable size classes from File Inspector and every greyed constraints runs out, you can re-enable them again if you need them. Hope it helps.

What are IOS constraints?

With constraints, you can say “these items are always lined up in a horizontal row” or “this item resizes itself to match the height of that item.” Constraints provide a layout language that you add to views to describe geometric relationships. The constraints you work with belong to the NSLayoutConstraint class.

What does constrain to margins mean in Xcode?

Feb 25, 2015 at 9:01. It is worth it to point out that when adding new constraints, newer versions of Xcode allow you to uncheck a box for "Constrain to Margins" that sets the same "Relative to Margins" flag. This is useful because it saves a few clicks!

What is IOS Autolayout?

Auto Layout is a constraint-based layout system. It allows developers to create an adaptive interface that responds appropriately to changes in screen size and device orientation.


4 Answers

There are a few ways to delete the constraints from the Storyboard

  1. Try not to delete from the Storyboard object because sometimes different constraints can stack together and you might delete the wrong one. So, it is better to delete from the Document Outline. Just highlight the constraint that you want to delete on the Document Outline and just press delete button on your keyboard. See screen shot below: enter image description here

  2. If you want to clear all the constraints from a selected view, Select the View (eg: A button), Tap on the Third Button (Resolve Auto Layout Issues Button), Tap Clear Constraints. enter image description here

  3. If you want to clear all the constraints for all the views inside the view controller, Highlight the right view controller Object inside the storyboard, Tap on the Third Button (Resolve Auto Layout Issues Button), Tap Clear Constraints under the "All Views in the View Controller".

like image 51
Ricky Avatar answered Oct 22 '22 14:10

Ricky


Double click the grayed out constraint (switches focus to the constraint) then press delete. This will delete the constraint.

like image 27
waynchi Avatar answered Oct 22 '22 14:10

waynchi


I believe the answer to the following question is that you can have same constraint selectively "installed" (or to my understanding, enabled) for different size classes. After you select a constraint from Document Outline, you can click on the + sign to Add Size Class Customization from the bottom of Attribute Inspector. So when you delete a constraint from the Size Inspector, you're basically deleting a constraint for a particular size class only. In order to delete a constraint for all size classes, you have to delete from Document Outline.

Why? Why can't you completely delete a constraint from the size inspector?!

like image 29
Sam Avatar answered Oct 22 '22 15:10

Sam


You can not delete grayed out constraints from the right hand Size Inspector (which is where I normally delete constraints because it's much easier to ascertain which view the constraints are for, it get's really confusing in the Document Outline), but you can delete the same grayed out constraints from the Document Outline on the left by selecting them and hitting the delete button.

Example of grayed out constraint (see height):

enter image description here

Note: To make the Document Outline's constraints easier to digest, I first delete them from the Size Inspector, which grays them out, then delete the newly grayed out constraint from the Size Inspector. Just FYI.

like image 41
RyJ Avatar answered Oct 22 '22 14:10

RyJ