ios - Prevent Interface Builder from auto creating Constraints? -
i created demo project here. have view created scrollview in .xib file. in interface builder did not set constraints. in viewdidload method set constraints snapkit:
scrollview.snp_makeconstraints { (make) -> void in make.edges.equalto(self.view) }
when run code following console output:
unable simultaneously satisfy constraints. @ least 1 of constraints in following list 1 don't want. try this: (1) @ each constraint , try figure out don't expect; (2) find code added unwanted constraint or constraints , fix it. (note: if you're seeing nsautoresizingmasklayoutconstraints don't understand, refer documentation uiview property translatesautoresizingmaskintoconstraints) ( "<nsibprototypinglayoutconstraint:0x7b74e280 'ib auto generated @ build time view fixed frame' v:|-(1)-[uiscrollview:0x7b74c430] (names: '|':uiview:0x7b74dd10 )>", "<<deviceimagestest.layoutconstraint:0x7baa2760> <uiscrollview:0x7b6608d0>.top == <uiview:0x7b64d800>.top>" ) attempt recover breaking constraint <nsibprototypinglayoutconstraint:0x7b74e280 'ib auto generated @ build time view fixed frame' v:|-(1)-[uiscrollview:0x7b74c430] (names: '|':uiview:0x7b74dd10 )> break on objc_exception_throw catch in debugger. methods in uiconstraintbasedlayoutdebugging category on uiview listed in <uikit/uiview.h> may helpful. 2015-05-29 18:37:14.368 deviceimagestest[36462:607] unable simultaneously satisfy constraints. @ least 1 of constraints in following list 1 don't want. try this: (1) @ each constraint , try figure out don't expect; (2) find code added unwanted constraint or constraints , fix it. (note: if you're seeing nsautoresizingmasklayoutconstraints don't understand, refer documentation uiview property translatesautoresizingmaskintoconstraints) ( "<nsibprototypinglayoutconstraint:0x7b74e080 'ib auto generated @ build time view fixed frame' h:|-(0)-[uiscrollview:0x7b74c430](ltr) (names: '|':uiview:0x7b74dd10 )>", "<nsibprototypinglayoutconstraint:0x7b74e330 'ib auto generated @ build time view fixed frame' h:[uiscrollview:0x7b74c430(600)]>", "<<deviceimagestest.layoutconstraint:0x7baa7170> <uiscrollview:0x7baa7b30>.right == <uiview:0x7baa79a0>.right>", "<nsautoresizingmasklayoutconstraint:0x7baa4800 h=-&- v=-&- uiview:0x7b74dd10.width == uiviewcontrollerwrapperview:0x7ba9f060.width>", "<nsautoresizingmasklayoutconstraint:0x7baa5180 h=-&- v=-&- uiviewcontrollerwrapperview:0x7ba9f060.width == uinavigationtransitionview:0x7bc769b0.width>", "<nsautoresizingmasklayoutconstraint:0x7baa58e0 h=-&- v=-&- uinavigationtransitionview:0x7bc769b0.width == uilayoutcontainerview:0x7bc75140.width>", "<nsautoresizingmasklayoutconstraint:0x7baa61a0 h=-&- v=-&- uilayoutcontainerview:0x7bc75140.width == uiwindow:0x7bc71870.width>", "<nsautoresizingmasklayoutconstraint:0x7baa69a0 h=--- v=--- h:[uiwindow:0x7bc71870(320)]>" ) attempt recover breaking constraint <<deviceimagestest.layoutconstraint:0x7baa95b0> <uiscrollview:0x7baa9610>.right == <uiview:0x7baa96b0>.right> break on objc_exception_throw catch in debugger. methods in uiconstraintbasedlayoutdebugging category on uiview listed in <uikit/uiview.h> may helpful. 2015-05-29 18:37:14.496 deviceimagestest[36462:607] unable simultaneously satisfy constraints. @ least 1 of constraints in following list 1 don't want. try this: (1) @ each constraint , try figure out don't expect; (2) find code added unwanted constraint or constraints , fix it. (note: if you're seeing nsautoresizingmasklayoutconstraints don't understand, refer documentation uiview property translatesautoresizingmaskintoconstraints) ( "<nsibprototypinglayoutconstraint:0x7b74e360 'ib auto generated @ build time view fixed frame' v:[uiscrollview:0x7b74c430(600)]>", "<<deviceimagestest.layoutconstraint:0x7bc77e40> <uiscrollview:0x7bc7f6a0>.top == <uiview:0x7bc52180>.top>", "<<deviceimagestest.layoutconstraint:0x7bc49420> <uiscrollview:0x7bc74b00>.bottom == <uiview:0x7bc7b970>.bottom>", "<nsautoresizingmasklayoutconstraint:0x7baa4960 h=-&- v=-&- uiview:0x7b74dd10.height == uiviewcontrollerwrapperview:0x7ba9f060.height>", "<nsautoresizingmasklayoutconstraint:0x7baa51e0 h=-&- v=-&- uiviewcontrollerwrapperview:0x7ba9f060.height == uinavigationtransitionview:0x7bc769b0.height>", "<nsautoresizingmasklayoutconstraint:0x7baa5940 h=-&- v=-&- uinavigationtransitionview:0x7bc769b0.height == uilayoutcontainerview:0x7bc75140.height>", "<nsautoresizingmasklayoutconstraint:0x7baa6200 h=-&- v=-&- uilayoutcontainerview:0x7bc75140.height == uiwindow:0x7bc71870.height>", "<nsautoresizingmasklayoutconstraint:0x7baa69d0 h=--- v=--- v:[uiwindow:0x7bc71870(568)]>" ) attempt recover breaking constraint <<deviceimagestest.layoutconstraint:0x7bc84790> <uiscrollview:0x7bc848b0>.bottom == <uiview:0x7bc84860>.bottom> break on objc_exception_throw catch in debugger. methods in uiconstraintbasedlayoutdebugging category on uiview listed in <uikit/uiview.h> may helpful.
it seems interface builder generating constraints me if did not set any. leads conflict constraints set in code. set settranslatesautoresizingmasks(false)
.
how can prevent interface builder auto generating constraints?
if confused nsautoresizingmasklayoutconstraints in list, might because haven't called settranslatesautoresizingmasksintocontraints(false)
on view. (although, under impression snapkit you).
if confused nsibprototypinglayoutconstraint
, that's auto-generated constraint interface builder. rid of it, add top, bottom, leading , trailing constraints in interface builder , set them removed @ build time. more details that, have @ http://travisjeffery.com/b/2013/11/preventing-ib-auto-generated-at-build-time-for-view-with-fixed-frame/
update: url changed http://travisjeffery.com/b/2013/11/preventing-ib-auto-generated-at-build-time-for-view-with-fixed-frame-when-using-auto-layout/
Comments
Post a Comment