Thread 1: "Unable to activate constraint with anchors <NSLayoutYAxisAnchor:0x600002beeb00 \"UILabel:0x1270105c0.top\"> and <NSLayoutYAxisAnchor:0x600002beeb40 \"UIStackView:0x127010430.bottom\"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal."
⛔️ 에러 본문
📃 에러가 발생한 상황 (코드)
‼️ 원인 및 해결방법
원인은 나의 실수였다. titleLabel 이라고 작성해야하는 건데 timeLabel 이라고 다른 라벨과 착각하여 적었던 것. 따라서 상위 뷰와 하위 뷰를 연결시키고 접근권한을 주어야하는 addSubView가 상위뷰가 오타로 없었으니 이러한 에러 메세지를 띄운 것이다.
before
after
➕ 그외 사항
나의 경우 이번에러에서 단순 typo 로 인한 에러였지만, 해당 에러 메세지는 보통 다음과 같은 경우에 많이 발생한다. 상위 뷰와 하위 뷰를 연결시키고 접근권한을 주어야하는 addSubView 가 권한이 없는 상위 뷰에 접근하여 제약조건을 걸려고 하는 경우 발생한다.