gpt4 book ai didi

ios - 调用 NSLayoutConstraint.activateConstraints 会使约束无效吗?

转载 作者:行者123 更新时间:2023-12-01 20:05:22 26 4
gpt4 key购买 nike

我需要调用setNeedsUpdateConstraints调用后NSLayoutConstraint.activateConstraints ?如果有,适用于哪些情况?

最佳答案

调用 NSLayoutConstraint.activateConstraints 后是否需要调用 setNeedsUpdateConstraints?

简短的回答是不,activateConstraints旨在根据创建时提供的约束来调整 View 布局。另一方面,您通常使用 setNeedsUpdateConstraints在动画或布局条件发生变化时。

关于 setNeedsUpdateConstraints文档说:

Call this method on your application’s main thread when you want to adjust the layout of a view’s subviews. This method makes a note of the request and returns immediately. Because this method does not force an immediate update, but instead waits for the next update cycle, you can use it to invalidate the layout of multiple views before any of those views are updated. This behavior allows you to consolidate all of your layout updates to one update cycle, which is usually better for performance.

关于ios - 调用 NSLayoutConstraint.activateConstraints 会使约束无效吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39084747/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com