简体   繁体   English

如何将标签变成滚动标签?

[英]How to grow label into scrollable label?

We have a view that we want to have "grow" to be larger after it is tapped. 我们认为,希望在点击后使“增长”更大。 If it is too large to fit on the screen that area should be in a UIScrollView. 如果太大而无法容纳在屏幕上,则该区域应位于UIScrollView中。 The UIScrollView does not scroll. UIScrollView不滚动。 My guess is that I have my constraints wrong. 我的猜测是我的约束有误。 I'm not sure what debug tricks I should use to provide more information here for help. 我不确定应该使用哪些调试技巧在此处提供更多信息以寻求帮助。

The main view has an image that takes up about 2/3 of the screen, a view at the bottom, and then a view that has its bottom aligned with the top of the view at the bottom, so that it overlays the bottom area of the image (alpha transparency set at .5). 主视图的图像占据屏幕的约2/3,底部的视图,然后是其底部与底部的视图顶部对齐的视图,因此它覆盖了屏幕的底部区域。图像(alpha透明度设置为.5)。 This view has a scrollview, and that scroll view has a label. 该视图具有滚动视图,并且该滚动视图具有标签。 That label shows two lines of text. 该标签显示两行文本。 That is all laid out fine (and we don't want the scroll view to scroll at this point. I didnt code to prevent that; its just not scrolling). 一切都很好(并且我们现在不希望滚动视图滚动。我没有编写代码来防止这种情况;它只是不滚动)。

There is a tap gesture to that last view. 最后一个视图有一个轻击手势。 When its tapped, the text label is changed from two lines to 0 lines. 轻按时,文本标签将从两行更改为0行。 There's a height constraint using >= on the label. 标签上使用> =时存在高度限制。 There is a height constraint so that the view does not expand up into the navigation bar. 存在高度限制,因此视图不会向上扩展到导航栏中。 The views all grow to the right size. 视图全部增长到合适的大小。 Now if that text is so large that we are running into those limiting height constraints, we want that text to scroll. 现在,如果该文本太大,以至于我们遇到了限制高度的限制,那么我们希望该文本滚动。

Why won't the text scroll? 为什么文本不滚动? Scrolling is enabled. 启用滚动。 I dont know if I need to do something with the content size of the UIScrollView since the number of lines has changed. 我不知道是否需要更改UIScrollView的内容大小,因为行数已更改。

Without seeing your code, I can only speculate. 没有看到您的代码,我只能推测。 But a common omission is failing to set the contentSize property of your UIScrollView after its content have changed or moved. 但是,常见的遗漏是在内容更改或移动后无法设置UIScrollViewcontentSize属性。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM