简体   繁体   English

设置iOS助手的正确方法

[英]Correct method to setup iOS constriants

I just started using constraints in iOS. 我刚刚开始在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. 我记得阅读过在视图的updateConstraints方法中创建约束的信息。 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? 应该将我的约束添加到init并在updateConstraints更新,还是可以在updateConstraints方法中添加和更新约束?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在iOS中迅速删除StackLayoutView及其子视图之间的链接/约束 - Removing the link/constriants between the StackLayoutView and its child view in IOS swift ios 搜索栏文本字段背景与设置颜色不正确 - ios searchbar textfield background not correct as setup color 为IOS设置模型的正确方法是什么? - What is the correct way to setup a Model for IOS? 在cellForRowAtIndexPath方法中设置自定义单元格的正确方法? - Correct way to setup a custom cell in the cellForRowAtIndexPath method? 返回iOS UILabel方法的正确方法 - Correct way of returning iOS UILabel method iOS:在方法调用中使用CGBitmapContextCreate无法获得正确的结果 - iOS: not getting correct result with CGBitmapContextCreate in method call NSPanGestureRecognizer 自动布局约束 - NSPanGestureRecognizer Autolayout Constriants 设置Cookie并在发布方法中使用它,并在ios中的Webview中加载 - Setup Cookie and use it in post method and load in webview in ios iOS-从类中“监听”委托方法的正确方法 - iOS - Correct way to “listen” for a delegate method from within a class iOS:设置或增加文本字段宽度的正确方法 - iOS: Correct method to set or increase text field width
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM