Swift TextField 没有宽度 [英] Swift TextField has no width

查看:27
本文介绍了Swift TextField 没有宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习 swift 并且一直在尝试使用记分板创建布局.

I have just started learning swift and have been trying to create a layout using the scoreboard.

我已经放置了两个文本字段并使用文档大纲正确设置了约束.但是,当我运行模拟器时,文本字段显示错误.

I have placed two textfields and set the constraints properly using the document outline. However when I run the emulator the Text Fields display wrong.

我附上了一张截图,左边是我的模拟器中发生的事情,右边是我在 xCode 的视图编辑器中看到的

I have attached a screenshot, The left is what happens in my emulator the right is what I see in the view editor in xCode

推荐答案

您使用了错误的约束.....当您将 x 和 y 位置赋予屏幕边缘时,您无法保持 textview 的宽度...

You used the wrong constraints.....as you give x and y position to edges of the screen you can not maintain the width of the textview...

好的,这里有一些图片......只需按照它......

ok here is some images ...just follow it...

在第一个图像中,我只是将 x 和 y 位置以及高度和宽度赋予第一个文本字段,在第二个图像中,我为第一个文本字段提供相等的宽度和高度.

In first image i just give x and y position with height and width to first textfield and in the second one i give equal width and heigh to first one.

这篇关于Swift TextField 没有宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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