Centering subview's X in autolayout throws “not prepared for the constraint”

前端 未结 8 1255
予麋鹿
予麋鹿 2020-11-30 02:09

I have a custom UIView subclass which is being initialized via a nib.

In -awakeFromNib, I\'m creating a subview and attempting to center it in its super

8条回答
  •  眼角桃花
    2020-11-30 02:55

    In my case, it was solved by using root view as a container of constraints instead of a currently created view.

    I mean, use inside viewController

    view.addConstraints([leftConstraintImage, topConstraintImage]) instead of imageView.addConstraints...

提交回复
热议问题