jjzjj

setNeedsUpdateConstraints

全部标签

ios - swift 不确定 layoutIfNeeded setNeedsUpdateConstraints 或 updateConstraints setNeedsLayout

我正在调用API。根据我返回的json数据,我正在viewDidLoad()中修改我的ViewController,以便更改我的View设计以尽可能最好地显示给定数据。我所做的是隐藏一些uiViews并将它们的约束设置为.active=false但也改变了一些约束,例如:letnoCButton=NSLayoutConstraint(item:aListTop,attribute:NSLayoutAttribute.CenterY,relatedBy:NSLayoutRelation.Equal,toItem:aListBottom,attribute:NSLayoutAttribut

ios - 哪些操作会使约束失效?

UIView的updateConstraints方法有个注释:Youmustnotinvalidateanyconstraintsaspartofyourconstraintupdatephase.Youalsomustnotinvokealayoutordrawingphaseaspartofconstraintupdating.我不清楚什么会使约束无效。 最佳答案 通过一些实验,我发现简单地添加、删除或编辑约束不会自动调用setNeedsUpdateConstraints。事实上,我找不到任何方法让系统自动调用setNeedsU

ios - 哪些操作会使约束失效?

UIView的updateConstraints方法有个注释:Youmustnotinvalidateanyconstraintsaspartofyourconstraintupdatephase.Youalsomustnotinvokealayoutordrawingphaseaspartofconstraintupdating.我不清楚什么会使约束无效。 最佳答案 通过一些实验,我发现简单地添加、删除或编辑约束不会自动调用setNeedsUpdateConstraints。事实上,我找不到任何方法让系统自动调用setNeedsU

ios - 为什么约束更改或动画不需要调用setNeedsUpdateConstraints?

读物:从这个answer:这是被接受的答案建议为您的View动画设置动画:_addBannerDistanceFromBottomConstraint.constant=0UIView.animate(withDuration:5){self.view.layoutIfNeeded()}当不是更改框架时,为什么调用layoutIfNeeded。我们正在更改约束,因此(根据此otheranswer)我们不应该而是调用setNeedsUpdateConstraints吗?同样,此备受关注的answer说:Ifsomethingchangeslateronthatinvalidatesone

ios - setNeedsLayout 与 setNeedsUpdateConstraints 和 layoutIfNeeded 与 updateConstraintsIfNeeded

我知道自动布局链基本上包含3个不同的过程。更新约束布局View(这里是我们计算帧的地方)显示我不太清楚-setNeedsLayout和-setNeedsUpdateConstraints之间的内在区别。来自Apple文档:setNeedsLayoutCallthismethodonyourapplication’smainthreadwhenyouwanttoadjustthelayoutofaview’ssubviews.Thismethodmakesanoteoftherequestandreturnsimmediately.Becausethismethoddoesnotforc

ios - setNeedsLayout 与 setNeedsUpdateConstraints 和 layoutIfNeeded 与 updateConstraintsIfNeeded

我知道自动布局链基本上包含3个不同的过程。更新约束布局View(这里是我们计算帧的地方)显示我不太清楚-setNeedsLayout和-setNeedsUpdateConstraints之间的内在区别。来自Apple文档:setNeedsLayoutCallthismethodonyourapplication’smainthreadwhenyouwanttoadjustthelayoutofaview’ssubviews.Thismethodmakesanoteoftherequestandreturnsimmediately.Becausethismethoddoesnotforc