objective c - NSLayoutConstraints conflicts -


i'm trying add buttons programmatically view below nstextfield in view. view created in ib , uses constraints. nstablecellview, doubt makes difference in case. code thus:

nsview *previousview = self.pathsfield;  for( nsstring *path in self.revision.paths ) {     nsbutton *pb = [[nsbutton alloc] initwithframe: bframe];      pb.bezelstyle = nsroundrectbezelstyle;     [self addsubview: pb];     pb.title = path;     [self addconstraint: [nslayoutconstraint constraintwithitem: pb                                            attribute: nslayoutattributetop                                            relatedby: nslayoutrelationequal                                            toitem: previousview                                            attribute: nslayoutattributebottom                                            multiplier: 1 constant: 2.0]];     [buttons addobject: pb];     bframe.origin.y += 20;     previousview = pb; } self.pathbuttons = buttons; 

if take addconstraint call out buttons added no complaints (just not in right place). addconstraint call lot of messages constraint conflicts on debug console , of ib created constraints broken.

obviously i'm doing wrong. expected constraint require new button's top 2 px below bottom of previous view or button. doesn't seem should cause conflicts, off?

you making both kinds of mistake can make constraints: constraints both conflicted and ambiguous! rid of conflict setting translatesautoresizingmaskintoconstraints no, else has said, start worrying ambiguity. can use constraints if specify everything needed layout. specifying top that's all; need specify leading edge (left), , width , height (maybe not because button has intrinsic size; have experiment).


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -