简体   繁体   中英

Correct method to setup iOS constriants

I just started using constraints in iOS. I feel fairly comfortable with them, but now I'm wondering what's the proper way to create them. I remember reading to create the constraints in a view's updateConstraints method. But I see that doing so could lead to adding multiple copies of the same constraints. Is this true, or will an exact duplicate constraint not be added?

Should my constraints be added in the init and just updated in the updateConstraints or is it okay to add and update the constraints in the updateConstraints method?

根据Dave的评论,答案是在init创建初始约束。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM