此代码有什么问题?
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H: |-16-[v0]-16-|", options: NSLayoutFormatOptions(), metrics: nil, views:["v0" : thumbnailImageView]))
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V: |-16-[v0]-16-|", options: NSLayoutFormatOptions(), metrics: nil, views:["v0" : thumbnailImageView]))
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H: |[v0]|", options: NSLayoutFormatOptions(), metrics: nil, views:["v0" : sepratorView]))
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V: [v0(1)]|", options: NSLayoutFormatOptions(), metrics: nil, views:["v0" : sepratorView]))
我收到一个错误说 ' NSInvalidArgumentException',原因:'无法解析约束格式: 期待一个观点 H:| -16- [v0] -16- |
答案 0 :(得分:3)
在H:之后你有额外的空间,它必须是H:| -16- [v0] -16- | 。请注意空格,破折号和字符。