I add a UILabel (amountLabel) in UIViewController in storyboard editor. And then in swift file, viewDidLoad, I programatically create a UITextField (paymentTextField) and try to add a constraint be...
original source : https://stackoverflow.com/questions/35452908/swift-add-constraint-programmatically
뷰obj.addSubview(섭뷰obj) 를 통해 먼저 subview를 상부 view에 덧붙인다음 contraints를 적용해야 한다.
I ran into the same problem that you described earlier. In order to make the programmatic subview, (in your case the paymentTextField) you have to add this to the subview first and then apply your constraints.
By adding the subview to view first, this ensure both views have the same parent.
Very late, but hope this helps anybody else.
https://stackoverflow.com/a/41852169/3151712



















