TextField 覆盖在 ScrollView“调整以适合"上文本字段不起作用 [英] TextField overlaid on ScrollView "Adjust to Fit" TextField not working

查看:52
本文介绍了TextField 覆盖在 ScrollView“调整以适合"上文本字段不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由两个文本字段覆盖的滚动视图,一个靠近顶部,一个靠近底部.当文本字段中的文本达到侧面约束时,应用程序会冻结并且不会调整大小以适应宽度.最初,我有一个由两个文本字段覆盖的图像视图,并且它工作正常.我认为这与滚动视图有一些关系.

I have a scroll view overlaid by two text fields, one near the top and one near the bottom. When text in the text field reaches the side constraints the app freezes up and does not adjust the size to fit the width. Initially, I had a image view overlaid by two text fields and it was working properly. I think this has some relation to the scroll view.

在界面构建器中,选中调整以适合并设置最小字体大小.我也用过下面的说法,没用.

In the interface builder, Adjust to Fit is checked and min font size set. I also have used the following statements and no avail.

    topTextField.adjustsFontSizeToFitWidth = true
    bottomTextField.adjustsFontSizeToFitWidth = true

以下是应用程序冻结时的屏幕截图以及 Xcode 中布局的屏幕截图.

Below is a screen shot of the app when it freezes up and screen shot of the layout in Xcode.

推荐答案

看起来与自动布局约束有关.仔细检查滚动视图的约束.按照这个教程很好地解释了一步一步如何处理滚动视图的约束.

Looks like something to todo with Auto layout constraints. Double check constraints for scrollview .Follow this tutorial very well explained step by step how to handle constraints with scrollview.

这篇关于TextField 覆盖在 ScrollView“调整以适合"上文本字段不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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