I have found this question and answer here however I get the error
Type 'UIView!' does not conform to protocol 'AnyObject'
for
...
@IBOutlet var mainView: UIView!
@IBOutlet weak var contentView: UIView!
...
NSLayoutConstraint(item: self.contentView, ...`
Is there somthing happening with dereferencing the view object?
I was getting the same error after copy-pasting and trying to modify some Objective-C code into my swift project. I realized that I had left relatedBy as 0 instead of NSLayoutRelation.Equal. After fixing that the error went away. Weird that the compiler would show the error on the first parameter when it was really an issue with the relatedBy. Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With