【发布时间】:2017-01-19 14:47:24
【问题描述】:
我正在尝试向我的 repeatSegment 添加约束。
//Repeat Segment
repeatSegment?.setNeedsDisplay()
repeatSegment?.translatesAutoresizingMaskIntoConstraints = false
let repeatSegmentConstraint1 = NSLayoutConstraint(item: repeatSegment!, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.00, constant: 190) <<Error here
【问题讨论】:
-
也许我错了(很有可能),但你可以使用
self作为toItem中的值吗...不应该是self.view还是只是view?我的意思是...self在这种情况下是UIViewController -
你能再检查一下吗,我得到了新的错误
-
不要在问题中发布代码截图。复制并粘贴代码本身。我无法阅读问题中的代码。与错误消息相同。复制并粘贴文本。
-
我认为这会提供更多错误发生的原因。对不起
-
我找到了这个答案:stackoverflow.com/a/14033030/4063602(基本上,将约束添加到超级视图,而不是子视图。在你的情况下,
view而不是songSlider)