ios - 在 UITextField 中关闭键盘

标签 ios swift uitextfield uitextfielddelegate

有人能解决我的问题吗? 我有一个 UITextField 并想在按下 Return 后关闭键盘。 我添加了 UITextFieldDelegate 并想在我的 TextField 上设置委托(delegate),但错误仍然存​​在...

Here is a Screenshot of my Problem

最佳答案

您想使用哪个。 TextField 还是 TextView?

因为您创建了“TextView”的“IBOutlet”,但将委托(delegate)设置为“TextField”。

如果您想使用“TextField”,则从 Storyboard中删除“TextView”并使用“TextField”代替它并创建它的“IBOutlet”。

如果您想使用“TextView”,则使用“UITextViewDelegate”而不是“UITextFieldDelagate”。

关于ios - 在 UITextField 中关闭键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35553873/

相关文章:

swift - 限制我的玩家在 x 方向移动太多

ios - FacebookSDK 3.0 - Apple Mach-O 链接器错误

ios - 退出 'while' 循环后数组项被删除?

swift - 我在更新 xcode 后收到此错误 "No such module ' SwiftyJSON'

ios - 转换实现协议(protocol)的 View Controller

iOS UITextField 触摸完成后键盘没有隐藏。为什么?

uitextfield - 为什么解雇WithClickedButtonIndex不调用clickedButtonAtIndex?

ios - UITextView 在成为第一响应者时添加新行

ios - iOS 中,当用户通过 UISwipeGestureRecognizer 在 ImageView 中向左滑动时,如何在 ImageView 中显示 NextImage?

iphone - 如何将我的视频保存到相册中的特殊文件夹中?