内容拥抱优先动态单元格大小 [英] Content hugging priority Dynamic Cell Size

查看:155
本文介绍了内容拥抱优先动态单元格大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我有一个<一个href=\"http://stackoverflow.com/questions/30268865/complex-autolayout-for-cell-with-dynamic-size\">complex 了自动布局的情况已经得到解决(感谢@Catalina T.)。目前我遇到的内容拥抱优先级的问题。我有4个可能包含巨大文本所以细胞应适应内容的动态标签。随着当前制约和优先事项,如果我设置巨大的文本,以它完美的所有动态标签(尽管他们中的一个将不显示,而不是完全它将被裁剪点)。如果我设置了第三个标签的文本工程浩大自动布局都疯了......我得到的东西是这样的:

Recently I've had a complex auto layout situation that has been solved (thanks to @Catalina T.). Currently I'm experiencing an issue with Content Hugging Priority. I have 4 dynamic labels that may contain huge texts so cells should fit the content. With the current constraints and priorities if I set huge texts to all dynamic labels it works perfectly (though one of them won't be displayed fully instead it will be clipped with dots). If I set the third label's text to a huge one auto layout goes crazy... I get something like this:

虽然我不想被安排因此所有的标签。

Whereas I want all the labels to be arranged consequently.

演示项目

如何解决这个问题?

感谢你在前进!

推荐答案

我设法解决这个问题。

I managed to solve this issue.

自动版式应该知道前置,从所有的动态视图顶部和底部的约束。除此之外,它可能发生的一种观点是巨大的,有些则不是,因此,你会得到错误的安排。为了解决这个问题只需添加垂直间距对于那些尚未与该约束连接的每个动态视图。那么你应该约束的关联更改为大于或等于,所以你只需通知自动版式您希望这些意见进行安排。因此。

AutoLayout should know leading, trailing, top and bottom constraints from all your dynamic views. Besides that it might happen that one view is huge and others are not, as a result you'll get the wrong arrangement. To solve this simply add Vertical Spacing for each dynamic views that are not yet connected with this constraint. Then you should change the constraint Relation to Greater Than Or Equal, so you'll simply notify the AutoLayout that you want these views to be arranged consequently.

解决示范项目

这篇关于内容拥抱优先动态单元格大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆