I add a UILabel
(amountLabel) in UIViewController
in storyboard editor. And then in swift file, viewDidLoad
, I programatically create a
The error states that "because they have no common ancestor", which means that they don't share the same parent. In order to relate constraint between two items, they have to have a child-parent relationship or a sibling one.
In your case just make sure they have the same parent view before adding the constraint programmatically.