What happens with constraints when a view is removed

前端 未结 6 1552
無奈伤痛
無奈伤痛 2020-12-07 21:31

The question I have is simple but I couldn\'t find any information in the documentation.

What happens with layout constraints when a view is removed from the view hi

6条回答
  •  清歌不尽
    2020-12-07 22:30

    Be aware though, that if you have two independent parent views A and B, and a subview C, where C is currently a subview of A, with appropriate constraints, that calling [B addSubview:C] will NOT clear any constraints relating to A and C, and auto layout will start throwing exceptions, because those constraints no longer relate to views in the same hierarchy.

    You will need to call [C removeFromSuperview] explicitly to remove the constraints, before adding C to B.

    This is true on Mac OS X - I haven't checked iOS

提交回复
热议问题