0

它运行良好,除了我收到此错误之外没有任何问题。

截屏

下面是我的代码。

NSDictionary *views = @{@"container":self.containerView,
                        @"head":self.headImageView,
                        @"userName":self.userNameLabel,
                        @"userTitle":self.userTitleLabel,
                        @"line":self.infoSeparatorLine,
                        @"articleTitle":self.articleTitleLabel
                        };

float headWidthAndHeight = 50;
NSDictionary *metrics = @{@"headWH":@(headWidthAndHeight),
                        @"userLabelWH":@(headWidthAndHeight/2),
                        };

[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[container]|" options:0 metrics:nil views:views]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-10-[container]|" options:0 metrics:nil views:views]];


[self.containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-15-[head(headWH)]-5-[userName]-15-|" options:0 metrics:metrics views:views]];
[self.containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-15-[head(headWH)]-5-[userTitle]-15-|" options:0 metrics:metrics views:views]];
[self.containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[line]|" options:0 metrics:metrics views:views]];
[self.containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-15-[articleTitle]-15-|" options:0 metrics:metrics views:views]];


[self.containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[head(headWH)]-0-[line(1)]-8-[articleTitle]|" options:0 metrics:metrics views:views]];
[self.containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[userName(userLabelWH)]-0-[userTitle(userLabelWH)]" options:0 metrics:metrics views:views]];

以下是我在调试区域收到的错误消息。

截屏

我如何解决它?

4

1 回答 1

1
[self.containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[head(headWH)]-0-[line(1)]-8@999-[articleTitle]|" options:0 metrics:metrics views:views]];

将优先级更改为低于 1000 以破坏约束。

于 2016-06-03T00:49:31.710 回答