ios - Why do I receive an error that says 'Unable to simultaneously satisfy constraints.' for auto layout? -


enter image description herei trying pin button on 4 sides fix button object @ exact location arbitrarily placed at, getting following error when run it. insight or appreciated.

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)  ( "<_uilayoutsupportconstraint:0x9f494b0 v:[_uilayoutguide:0x9f40370(20)]>", "<_uilayoutsupportconstraint:0x9f3b6c0 v:|-(0)-[_uilayoutguide:0x9f40370]   (names: '|':uiview:0x9f3feb0 )>", "<_uilayoutsupportconstraint:0x9f418e0 v:[_uilayoutguide:0x9f407c0(0)]>", "<_uilayoutsupportconstraint:0x9f18010 _uilayoutguide:0x9f407c0.bottom == uiview:0x9f3feb0.bottom>", "<nslayoutconstraint:0x9f40f10 v:[uibutton:0x9f40f40'button']-(211)-[_uilayoutguide:0x9f407c0]>", "<nslayoutconstraint:0x9f47ab0 v:[_uilayoutguide:0x9f40370]-(539)-[uibutton:0x9f40f40'button']>", "<nslayoutconstraint:0xa157b10 'uiview-encapsulated-layout-height' v:[uiview:0x9f3feb0(568)]>" )  attempt recover breaking constraint  

make symbolic breakpoint @ uiviewalertforunsatisfiableconstraints catch in debugger. methods in uiconstraintbasedlayoutdebugging category on uiview listed in <uikit/uiview.h> may helpful. 

even @adrianb has basic understanding of comments in answer, explain in detail here:

let's view has size of 200 x 200, button of 100 x 20. (values having example). so, i. e., place left space of 80, right space of 20 (80+100+20=200) , top space of 100, bottom space of 80. (100+20+80=200).

now size of view changes. gets width of 300. constraint right , left still valid. borders still 80 , 20. way realize that, give button width of 200. (80+200+20=300). okay, maybe funny looking button, works.

but becomes hard in vertical direction, if view's height changes 300. button has grow in vertical direction 120. way top , bottom space stay valid. not think buttons that.

however becomes impossible, when view's height less 180, because space consumed constraints (top=100+bottom=80=180) there no space bottom more. height becomes negative.

that's problem.

now solution:

do not place button hard constraints 4 edges in auto layout. auto layout changing superviews size. in such case, meaningless.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -