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

前端 未结 6 1062
栀梦
栀梦 2021-02-06 21:20

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 constrain

相关标签:
6条回答
  • 2021-02-06 21:47

    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:

    1. You select the view and Xcode shows related constraints.
    2. You try to choose the one that is outside of selected view.
    3. You fail (end with selecting the view beneath the constraint)

    enter image description here

    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.

    enter image description here

    0 讨论(0)
  • 2021-02-06 21:51

    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.

    0 讨论(0)
  • 2021-02-06 22:03

    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.

    0 讨论(0)
  • 2021-02-06 22:07

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

    0 讨论(0)
  • 2021-02-06 22:08

    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.

    0 讨论(0)
  • 2021-02-06 22:10

    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.

    0 讨论(0)
提交回复
热议问题