Xcode - 元素对另一个元素的约束

时间:2016-11-14 06:46:51

标签: ios iphone xcode

我想知道为什么会出现这种情况? 我已经使用了应该适用于应用程序布局对齐的标准编码,这应该是完美的。 而且我不知道它为什么不起作用。

@"V:[individualCheckBox]-%lu-[businessDistributionCheckBox]"

平均值是在单个CheckBox和业务之间分配CheckBox会有约束吗?但我不知道为什么所有的CSS和个人都有空间

代码:

    selectNatureButton.translatesAutoresizingMaskIntoConstraints = NO;
    [scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[selectIndividualButton]-15-[selectNatureButton]-15-|"
                                                                       options:0
                                                                       metrics:nil
                                                                         views:NSDictionaryOfVariableBindings(selectIndividualButton,selectNatureButton)]];
    [scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[individualLabel]-15-[selectNatureButton]"
                                                                       options:0
                                                                       metrics:nil
                                                                         views:NSDictionaryOfVariableBindings(individualLabel, selectNatureButton)]];
    [selectNatureButton addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[selectNatureButton(==120)]"
                                                                               options:0
                                                                               metrics:nil
                                                                                 views:NSDictionaryOfVariableBindings(selectNatureButton)]];
    [selectNatureButton addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectNatureButton(==40)]"
                                                                               options:0
                                                                               metrics:nil
                                                                                 views:NSDictionaryOfVariableBindings(selectNatureButton)]];



    moreIndividualButton.translatesAutoresizingMaskIntoConstraints = NO;
    [scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-15-[moreIndividualButton]-15-|"
                                                                       options:0
                                                                       metrics:nil
                                                                         views:NSDictionaryOfVariableBindings(moreIndividualButton)]];
    [scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[selectIndividualButton]-15-[moreIndividualButton]"
                                                                       options:0
                                                                       metrics:nil
                                                                         views:NSDictionaryOfVariableBindings(selectIndividualButton, moreIndividualButton)]];
    [moreIndividualButton addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[moreIndividualButton(==150)]"
                                                                                 options:0
                                                                                 metrics:nil
                                                                                   views:NSDictionaryOfVariableBindings(moreIndividualButton)]];
    [moreIndividualButton addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[moreIndividualButton(==40)]"
                                                                                 options:0
                                                                                 metrics:nil
                                                                                   views:NSDictionaryOfVariableBindings(moreIndividualButton)]];

    individualLayoutConstraint = [NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:@"V:[individualCheckBox]-%lu-[businessDistributionCheckBox]", (([selectedIndividualMutableArray count] + 1) * 60 + 60)]
                                                                         options:0
                                                                         metrics:nil
                                                                           views:NSDictionaryOfVariableBindings(individualCheckBox, businessDistributionCheckBox)];
    NSLog(@"ans: %lu", (([selectedIndividualMutableArray count] + 1) * 60 + 60) );

    [scrollView addConstraints:individualLayoutConstraint];`

0 个答案:

没有答案