0
私の自動制約で何が起こっているのかわからないので、私はあなたの助けが必要です。私のスイッチの制約は、アプリケーションをクラッシュさせる。私はそれらを削除するとうまく動作します。 これは私が受け取るエラーメッセージです: '|'を解釈できません関連するビューはスーパービューを持たないため、文字: H:| -100- [v0(35)] |'|'を解釈できません文字
class selectionCustomCell: UITableViewCell{
var label: UILabel = {
let attribution = UILabel()
attribution.text = "Nom du label"
attribution.textColor = UIColor(r: 0, g: 185, b: 255)
attribution.lineBreakMode = NSLineBreakMode.ByWordWrapping
attribution.numberOfLines = 0
attribution.translatesAutoresizingMaskIntoConstraints = false
return attribution
}()
var switchElement: UISwitch{
let sL = UISwitch()
sL.setOn(true, animated: true)
sL.onTintColor = UIColor(r: 0, g: 185, b: 255)
sL.tintColor = UIColor(r: 0, g: 185, b: 255)
sL.translatesAutoresizingMaskIntoConstraints = false
return sL
}
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: .Default, reuseIdentifier: reuseIdentifier)
addSubview(switchElement)
addSubview(label)
setupViews()
}
func setupViews(){
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-20-[v0]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": label]))
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-20-[v0]", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": label]))
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-100-[v0(35)]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": switchElement]))
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-20-[v0(35)]", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": switchElement]))
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Thxを。できます !!!私は私の髪を引っ張っていた –