如何用键盘移动 UITextFeild 以避免阻塞 [SWIFT 5+ ]
我知道关于这个主题有几个问题,但我在 [SWIFT 5.0] 或更高版本上找不到任何问题,非常感谢您的帮助。
我在屏幕底部有一个 UITextFeild,每次用户单击它时它都会被隐藏。有没有一种最近的方法可以解决这个隐藏问题,通过键盘后面的文本字段到顶部或出现在键盘顶部的示例字段。任何帮助将不胜感激,谢谢!
I know that there are several questions on this topic, but i have not been able to find any on [SWIFT 5.0] or more, and would really appreciate your help.
I have a UITextFeild at the bottom of the screen which gets hidden every time the user clicks on it. Is there a recent method on which i can solve this hiding issue, by either the textFeild following the keyboard to the top or a sample field appearing on top of the keyboard. Any help would be greatly appreciated, thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下代码:
首先,在控制器 viewDidLoad() 方法中添加这两行代码:
其次,在控制器中添加这两个方法:
Enjoy :)。
You can use the following code:
First, add these two lines of code in your controller viewDidLoad() method:
Second, add these two methods inside your controller:
Enjoy :).
如果您使用 AutoLayout,您可以尝试使用我的名为 SwiftToolkit
将此代码添加到您的控制器
viewDidLoad()
方法中:当键盘出现时,它将推送您的UITextField 像这样:
If you use AutoLayout you may try
Keyboard
andKeyboardLayoutGuide
from my collection of handy Swift extensions and classes called SwiftToolkitAdd this code to your controller
viewDidLoad()
method:When the keyboard appears it will push your UITextField up like this: