ios - sizes - xcode constraints tutorial




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

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?


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


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?!


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:

  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.

  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".


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):

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.





xcode6