标签不显示滚动视图中的所有文本

Label doesn#39;t show all the text inside scrollView(标签不显示滚动视图中的所有文本)

本文介绍了标签不显示滚动视图中的所有文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望 DecriptionLabel(Lorem Ipsum 之一)使其中的所有文本都可见.如您所见,它正在被修剪.

I want the DecriptionLabel (the Lorem Ipsum one) to have all the text inside it visible. As you can see, it is getting trimmed.

这两个按钮应该在其他所有东西的下方,但是在 DescriptionLabel 包含小文本的情况下,按钮应该贴在视图的底部.

The two buttons should be under everything else, but in the case where DescriptionLabel contains a small text, the buttons should stick to the bottom of the view.

这就是为什么我选择按钮和 DescriptionLabel 之间的 >= 20 距离(如果有意义的话).

This is why I chose a >= 20 distance between the buttons and DescriptionLabel if it makes any sense.

如何解决文本的修剪问题?

How can I solve the trimming of the text?

谢谢.

推荐答案

我最初是在回答 如果内容不够大,如何让按钮粘在滚动视图的底部?但是因为它被标记为这个的副本我在这里发布我的答案.请尝试通过以下方式设置约束:https://imageshack.com/a/img923/6671/Txzu98.png
诀窍是您将 Button.Bottom Equal To ContainerView.Bottom 设置为 lower priority(我使用 750)而不是 Button.Top 大于或等于 Label.底部(这里我使用默认1000)
标签的行数必须设置为 0.
按钮的高度应由高度约束设置(在本例中为 50).
容器视图高度约束应具有低优先级(在这种情况下 250)
您应该运行代码以查看设备或模拟器上的实际结果.故事板显示它有点不同.

对于当前问题:https://imageshack.com/a/img923/7276/tQeT0h.png
基本思路是一样的.
Button Down 与上述答案中的 Button 具有相同的约束,但没有 Button.Top 大于或等于 Label.Bottom.
Button Up 和 Button Down 之间应该有固定的垂直约束.我正在设置具有固定高度的 Button Up 并设置尾随和前导约束等于 Button Down 的尾随和前导.
约束 Button.Top 大于或等于 Label.Bottom 现在是 Button Up.Top 大于或等于 Label.Bottom

I was originally answering How to make button stick to bottom of scroll view if the content isn't large enough? but since it is marked as duplicate of this one I am posting my answer here. Please try to set your constraints the following way: https://imageshack.com/a/img923/6671/Txzu98.png
The trick is that you set Button.Bottom Equal To ContainerView.Bottom with lower priority (I use 750) than Button.Top Greater Than Or Equal To Label.Bottom (Here I use default 1000)
The Label has to have number of lines set to 0.
The height of the button should be set by height constraint (in this case is 50).
The Container View Height constraint should be with low priority (in this case 250)
You should run the code to see actual result on device or simulator. Storyboard shows it a bit differently.

For the current question: https://imageshack.com/a/img923/7276/tQeT0h.png
The basic idea is the same.
Button Down has the same constraints as Button from above answer without Button.Top Greater Than Or Equal To Label.Bottom.
There should be fixed vertical constraint between Button Up and Button Down. I am setting Button Up with fixed Height and setting trailing and leading constraint equal to trailing and leading of Button Down.
The constraint Button.Top Greater Than Or Equal To Label.Bottom is now Button Up.Top Greater Than Or Equal To Label.Bottom

这篇关于标签不显示滚动视图中的所有文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:标签不显示滚动视图中的所有文本

基础教程推荐