objective c - Views not displaying correctly after adding them to NSStackView programatically -
so, i'm trying add views (nstextfield in example) nsstackview:
i've added nsstackview instance xib file, linked outlet widgets document. in ...didloadnib i'm doing this:
nstextfield *tf = [[nstextfield alloc] init]; tf.stringvalue = @"124"; [tf setframesize:nsmakesize(100, 20)]; [widgets addview:tf ingravity:nsstackviewgravityleading]; nslog(@"%f - %d", nsheight(tf.frame), [tf hasambiguouslayout]); nstextfield *tf2 = [[nstextfield alloc] init]; tf2.stringvalue = @"123"; [tf2 setframesize:nsmakesize(100, 20)]; [widgets addview:tf2 ingravity:nsstackviewgravityleading]; nslog(@"%f - %d", nsheight(tf2.frame), [tf2 hasambiguouslayout]);
textfields placed stackview, they're placed same position, i.e. second overlaps first completely. still can select first [space+tab].
here's console output:
2015-06-13 17:11:00.736 celty-test[62306:9217679] 20.000000 - 1 2015-06-13 17:11:00.739 celty-test[62306:9217679] unable simultaneously satisfy constraints: ( "<nslayoutconstraint:0x608000084bf0 v:[nsstackviewspacer:0x6080001834d0(>=8)]>", "<nslayoutconstraint:0x608000084f10 v:[nstextfield:0x608000183330]-(0)-[nsstackviewspacer:0x6080001834d0]>", "<nslayoutconstraint:0x608000085460 v:[nsstackviewspacer:0x6080001834d0]-(0)-[nstextfield:0x608000183400]>", "<nsautoresizingmasklayoutconstraint:0x608000084970 h=--& v=--& v:[nstextfield:0x608000183330]-(0)-| (names: '|':nsstackviewcontainer:0x6000001a0700 )>", "<nsautoresizingmasklayoutconstraint:0x608000084d30 h=--& v=--& v:[nstextfield:0x608000183400]-(0)-| (names: '|':nsstackviewcontainer:0x6000001a0700 )>", "<nsautoresizingmasklayoutconstraint:0x608000084d80 h=--& v=--& v:[nstextfield:0x608000183400(20)]>" ) attempt recover breaking constraint <nslayoutconstraint:0x608000084bf0 v:[nsstackviewspacer:0x6080001834d0(>=8)]> set nsuserdefault nsconstraintbasedlayoutvisualizemutuallyexclusiveconstraints yes have -[nswindow visualizeconstraints:] automatically called when happens. and/or, break on objc_exception_throw catch in debugger. 2015-06-13 17:11:00.802 celty-test[62306:9217679] unable simultaneously satisfy constraints: ( "<nslayoutconstraint:0x608000084f10 v:[nstextfield:0x608000183330]-(0)-[nsstackviewspacer:0x6080001834d0]>", "<nslayoutconstraint:0x608000085460 v:[nsstackviewspacer:0x6080001834d0]-(0)-[nstextfield:0x608000183400]>", "<nsautoresizingmasklayoutconstraint:0x608000084970 h=--& v=--& v:[nstextfield:0x608000183330]-(0)-| (names: '|':nsstackviewcontainer:0x6000001a0700 )>", "<nsautoresizingmasklayoutconstraint:0x608000084d30 h=--& v=--& v:[nstextfield:0x608000183400]-(0)-| (names: '|':nsstackviewcontainer:0x6000001a0700 )>", "<nsautoresizingmasklayoutconstraint:0x608000084d80 h=--& v=--& v:[nstextfield:0x608000183400(20)]>" ) attempt recover breaking constraint <nslayoutconstraint:0x608000085460 v:[nsstackviewspacer:0x6080001834d0]-(0)-[nstextfield:0x608000183400]> set nsuserdefault nsconstraintbasedlayoutvisualizemutuallyexclusiveconstraints yes have -[nswindow visualizeconstraints:] automatically called when happens. and/or, break on objc_exception_throw catch in debugger. 2015-06-13 17:11:00.814 celty-test[62306:9217679] 20.000000 - 0
xib , result screenshots:
there's no constraints added stackview. stackview should vertical. there dynamic amount of textfields added stackview.
you need set translatesautoresizingmaskintoconstraints
property of text fields false.
normally, shouldn't if view being placed other code. is, expect stack view decide whether property should on or off because it's in control of placing view hierarchy. however, there's bug in nsstackview
regards through 10.10, have turn off yourself.
the clue set of unsatisfiable constrains include ones of type nsautoresizingmasklayoutconstraint
.
Comments
Post a Comment