ねえ、私はこのようなセットアップを持っている:トラブル調整の制約は、プログラム
左制約は、私が20にこの制約を変更し、箱の長さを増やしたい111の定数です。現在、私は持っている:私はもともとleadingConstraint = NSLayoutConstraint(item: view.superview!, attribute: .Leading, relatedBy: .Equal, toItem: greenView, attribute: .Trailing, multiplier: 1.0, constant:20)
でエラーが発生しました
@IBAction func didTapButton(sender: AnyObject) {
view.removeConstraint(leadingConstraint)
leadingConstraint = NSLayoutConstraint(item: view.superview!, attribute: .Leading, relatedBy: .Equal, toItem: greenView, attribute: .Leading, multiplier: 1.0, constant:20)
view.addConstraint(leadingConstraint)
}
。だから私はそれを両方の属性の.Leadingと.Leadingに変更しました。今矩形が伸びているが、それは正しいサイズではありません、それは画面をオフに起こっている:
私はここで間違って何をしているのですか? (注:定数を変更するだけでなく、新しい制約を追加することで、これらの制約を変更したいと思っています。これについてのあらゆる指針は非常に高く評価されるでしょう!おかげ
これはあなたの質問に対する答えではありませんが、将来のための良い提案です: 'view.addConstraint(someConstraints)'をこれまでに使用しないでください!代わりに 'NSLayoutConstraint.activateConstraints(someConstraints)'または 'someConstraint.active = true'を使用してください – DevAndArtist