How do I (easily) delete a constraint in Interface Builder in Xcode 6 - xcode

Assume you've selected an object and you have the Size Selector in the Utilities panel open. You can see the list of constraints applied to the object. In the list of constraints you could click on the little gear and pick delete. You can't in Xcode 6.
There are still several ways to delete constraints in IB:
Find the constraint in the Document Outline and delete it that way (but it can be hard to find).
Click on the little bar in the storyboard and delete it that way (which can be hard to click on).
Double click on the constraint in the Size Selector which will open Attribute Inspector and highlight the constraint in the Document Outline. This can be a nuisance when you want to delete several.
Still, I miss ease of use of the gear delete feature and I'm wondering if it's still there in a similar fashion and I just can find it. While the other ways work, I find myself wasting lots of time especially when playing with the new Size Classes feature. So, find a easier way to delete them?

In Xcode6 (Beta5) when I click on a particular constraint in the Size inspector, it acquires a thin blue border. The constraint can then be deleted using the backspace.

The accepted answer is right, but there is so much frustration with selecting constraints that lay outside of selected view that I decided to add this tips as another answer.
I found incredible list of tips that helped me to solve this problem.
The problem:
You select the view and Xcode shows related constraints.
You try to choose the one that is outside of selected view.
You fail (end with selecting the view beneath the constraint)
Soulution:
Click it with Shift+Ctrl pressed and you'll see a menu of all the views that exist where you've clicked.
To delete selected constraint press delete key.

The selected answer is incomplete. When you delete the constraint from the Size Inspector, you are leaving behind the constraint object in the Document Outline pane. It is greyed out, meaning it is not used, but still exists and, what's worse, will affect auto layout with errors, warnings or conflicting constraints and you will go crazy until you also delete them from the Document Outline pane.
So:
1. Delete the constraint from the Size Inspector as in the accepted answer
2. Delete any greyed out constraints from the Document Outline
Live a happy, constraint-free life.

This answer from #wayne chi is the simplest, and spares you from hunting down constraints in Document Outline:
Double click the grayed out constraint (switches focus to the constraint) then press delete. This will delete the constraint.

Sometimes, the easiest way is to close the file in Xcode and edit it with a text editor. :-/

If you want to delete ALL constraints from a viewController simply turn off auto layout and then reenable it (or don't) and all of the constraints will be gone.

Related

How to quickly snap a view in storyboard back into its constraints after accidentally moving it

Everything I have found, every one says this cant be done.
I studied in fullsail university and they taught me how to do this so I know without a doubt it can be done. No one just knows how and assumes it can't.
Basically, when in XCode-story board, I would add constraints to a view and everything is all blue and perfect. From there, if you click, hold a drag, the view to another position then all of the constraints will turn orange. (Not RED because the constraints are still good it just simply needs to snap back into place..)
When in school my teacher taught me a quick key short cut that you press and everything snaps back into place and its all blue again. It has been a while since I have coded and i am just now getting back into it again and i just cant remember what that shortcut was.
I hope someone out there knows how to do this. Maybe any fullsail graduates?
Your responses are greatly appreciated.
I figured it out.
option + CMND + '='
What you're looking to do is referred to as "Update(ing) Frames."
The quick command is indeed option-command-equals
The command can also be reached from the bottom menu of a storyboard.
This link may change in the future but check out the Auto Layout Guide. Specifically reference the "Resolve Auto Layout Issues Tool" section.

Find a constraint using the hex code

I have some issues with auto layout, where the console says there are conflicting constraints. However, when Xcode attempts to fix the issue, everything works as intended. In the console it reports
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fe578db22f0 V:[UILabel:0x7fe578d9b200'Label'(32)]>
I want to find the constraint mentioned: "0x7fe578db22f0" and delete it manually.
Is there anyway to find it by using that hex code? And if not, can anyone suggest a way to fix my issue? I have a lot of constraints and it would be very difficult to go through and test each one.
If the question is merely how to identify which view that constraint is associated with, the easiest way is probably using the view debugger. So, run the app and click on the "debug view hierarchy" button. Then examine your view hierarchy in the left panel (narrowing it down by searching for view type, if you want), until you see a constraint that looks like the one in question. And by choosing the object inspector, you can confirm the address of the constraint in question.
Now that you've identified the precise constraint and view in question, the tracking down of its creation in the app should be much easier.
Add UIViewAlertForUnsatisfiableConstraints symbolic breakpoint help you debug autolayout easier !

How To Reset A Size Class Auto-Layout Back To Its wAny hAny Defaults?

I am working on a specific size class layout of an xcode project and I hit a snag.
My constraints got very messed up and I want to restart the view.
Is there a way in the interface builder for me to reset a size class (e.g wAny hCompact) back to its any constraints settings? (i.e. back to how it was with wAny hAny)
This should really be an automatic process in Interface Builder, but as far as I know it is not so you have to do the dirty work.
The best solution I have found is a combination of using Interface Builder and the source editor for this task. Remember that there are two things to reset, both the auto-layout constraints as you are referring to, but also the variations you might have created. Lets start with auto-layout constraints, and deal with variations later:
Reseting auto-layout constraints
Find a constraint you want to reset. Choose the "Show Size Selector" panel in the utilities view. At the bottom you will see the size classes this constrain has been added to. If it is only installed on the size class you want to reset, you can delete the whole constraint, otherwise, just delete it from the size class you want to reset by clicking the cross.
Variations
I have only managed to reset variations using the source editor. Either use an external editor, or "Open As -> Source Code", and search for variation elements. Make sure the size class key is correct, and delete at will.
Found a quick fix for this.
In the Storyboard go to the file inspector tab, then, under "Interface Builder Document" Section, uncheck the "Use Size Classes" checkbox and it will ask you to keep either iPhone or iPad current layout.
After choosing it, you can check "Use Size Classes" again and the other size classes will reset to the one you chose before.
Note: All other size classes will reset to the chosen class!

Reset a size class (i.e. Compact W/Compact H) to Any W/Any W on XCode 6

Loving XCode 6/iOS8's new way (using size classes) of doing Autolayouting (despite it being a pretty hard puzzle to solve at times).
But how does one reset one of the size classes back to Any/Any?
Set you size class to wAny hAny
Now you should see constraints installed outside this size class as greyed out in the pane on the left:
Select this constraint in the list and in the detail inspector pane on the right you should see this:
Here you see I installed a wRegular hAny constraint.
Hit the little x to delete this constraint in this size class.
Repeat for any other constraints you have.
Once these constraints are no longer installed in any size classes you can select and delete them in the left pane.
When you click on the Width/Height, take your cursor to the middle square and select it. That will set it at Any/Any.
Edit: I think I may have misunderstood. If, for example, you are working in wCompact hRegular, and you don't want those changes anymore and you want it to "inherit" from Any/Any, then you'll have to go about either uninstalling or deleting the constraints you created specifically for that size class. When you have your view controller outline showing, and the constraints appearing, the ones not grayed out are active for that size class. Check each one to see if any are specific to the size class you're working in (such as wCompact hRegular).
You can also uninstall or delete any additional UI objects you added to that size class specifically.
Hope that helps.

Drop down window to edit Cocoa pop-up menu items

I'm relatively new to Cocoa and I would like to implement the ability to add or delete items from a pop-up menu in the same way that the OS X System Preferences/Network Location pop-up works. Selecting the 'Edit Locations...' option rolls down a window that provides the ability to add to, or delete from the existing Location list. My interest in doing things this way is as much about conforming to the relevant Human Interface Guidelines as having a way to dynamically change the menu content. (I have no real problem with the 'background' coding side of things, it's the user interface that's my primary issue at this stage.)
Is this a standard IB View?
On the surface, I can't see anything appropriate, but maybe that's just my inexperience. I'm assuming that, because this is not an uncommon sort of requirement, the task should be pretty straightforward and that Apple, or someone, would even have a relevant code sample to show how to define such a window.
Can anyone point me in the right direction?
Sorry for the late answer. I found this tutorial: http://cocoadevcentral.com/articles/000014.php

Resources