как добавить ограничения программно с использованием swift

<сильный>ограничения</сильный>

<сильный><их>программно</их></сильный>

<сильный>свифт</сильный>

uiview

я пытаюсь выяснить это с прошлой недели не вдаваясь дальше. итак, мне нужно, чтобы применить некоторые в используя этот код:

var new_view:uiview! = uiview(frame: cgrectmake(0, 0, 100, 100));new_view.backgroundcolor = uicolor.redcolor();view.addsubview(new_view);var constx:nslayoutconstraint = nslayoutconstraint(item: new_view, attribute: nslayoutattribute.centerx, relatedby: nslayoutrelation.equal, toitem: self.view, attribute: nslayoutattribute.centerx, multiplier: 1, constant: 0);self.view.addconstraint(constx);var consty:nslayoutconstraint = nslayoutconstraint(item: new_view, attribute: nslayoutattribute.centery, relatedby: nslayoutrelation.equal, toitem: self.view, attribute: nslayoutattribute.centery, multiplier: 1, constant: 0);self.view.addconstraint(consty);var constw:nslayoutconstraint = nslayoutconstraint(item: new_view, attribute: nslayoutattribute.width, relatedby: nslayoutrelation.equal, toitem: new_view, attribute: nslayoutattribute.width, multiplier: 1, constant: 0);self.view.addconstraint(constw);var consth:nslayoutconstraint = nslayoutconstraint(item: new_view, attribute: nslayoutattribute.height, relatedby: nslayoutrelation.equal, toitem: new_view, attribute: nslayoutattribute.height, multiplier: 1, constant: 0);self.view.addconstraint(consth);

но возвращается в xcode этот странный вывод:

2014-10-03 09:48:12.657 test[35088:2454916] unable to simultaneously satisfy constraints.  probably at least one of the constraints in the following list is one you don't want. try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (note: if you're seeing nsautoresizingmasklayoutconstraints that you don't understand, refer to the documentation for the uiview property translatesautoresizingmaskintoconstraints) ("<nslayoutconstraint:0x7fa4ea446830 uiview:0x7fa4ea429290.centerx == uiview:0x7fa4ea4470f0.centerx>","<nsautoresizingmasklayoutconstraint:0x7fa4ea4516c0 h=--& v=--& uiview:0x7fa4ea429290.midx == + 50>","<nslayoutconstraint:0x7fa4ea452830 'uiview-encapsulated-layout-width' h:[uiview:0x7fa4ea4470f0(375)]>","<nsautoresizingmasklayoutconstraint:0x7fa4ea446db0 h=-&- v=-&- 'uiview-encapsulated-layout-left' h:|-(0)-[uiview:0x7fa4ea4470f0]   (names: '|':uiwindow:0x7fa4ea444b20 )>")will attempt to recover by breaking constraint <nslayoutconstraint:0x7fa4ea446830 uiview:0x7fa4ea429290.centerx == uiview:0x7fa4ea4470f0.centerx>make a symbolic breakpoint at uiviewalertforunsatisfiableconstraints to catch this in the debugger. the methods in the uiconstraintbasedlayoutdebugging category on uiview listed in<uikit/uiview.h> may also be helpful.2014-10-03 09:48:12.658 test[35088:2454916] unable to simultaneously satisfy constraints.  probably at least one of the constraints in the following list is one you don't want. try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (note: if you're seeing nsautoresizingmasklayoutconstraints that you don't understand, refer to the documentation for the uiview property translatesautoresizingmaskintoconstraints)("<nslayoutconstraint:0x7fa4ea44d160 uiview:0x7fa4ea429290.centery == uiview:0x7fa4ea4470f0.centery>","<nsautoresizingmasklayoutconstraint:0x7fa4ea451b30 h=--& v=--& uiview:0x7fa4ea429290.midy == + 50>","<nslayoutconstraint:0x7fa4ea44cf00 'uiview-encapsulated-layout-height' v:[uiview:0x7fa4ea4470f0(667)]>","<nsautoresizingmasklayoutconstraint:0x7fa4ea452700 h=-&- v=-&- 'uiview-encapsulated-layout-top' v:|-(0)-[uiview:0x7fa4ea4470f0]  (names: '|':uiwindow:0x7fa4ea444b20 )>")will attempt to recover by breaking constraint <nslayoutconstraint:0x7fa4ea44d160 uiview:0x7fa4ea429290.centery == uiview:0x7fa4ea4470f0.centery>make a symbolic breakpoint at uiviewalertforunsatisfiableconstraints to catch this in the debugger. the methods in the uiconstraintbasedlayoutdebugging category on uiview listed in <uikit/uiview.h> may also be helpful.

можете ли вы помочь мне?спасибо большое