iphone - 通过单击键盘按钮关闭屏幕键盘的事件

标签 iphone ios xcode cocoa-touch

我一直在到处寻找......也许我没有使用正确的搜索词,因为我相信这是一个常见的问题。

当用户通过单击按钮降低键盘来关闭键盘时,是否有我可以处理的事件。

The red marked button

当 uitextfield 变成 firstresponder 时,我向上移动一个 View ,但是当点击这个按钮时,我想再次向下移动它

最佳答案

尝试使用通知。将其添加到您的 viewDidLoad:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

然后创建一个名为keyboardWillHide的方法:

- (void)keyboardWillHide:(NSNotification *)notification {
  //do whatever you need
}

希望对你有帮助

关于iphone - 通过单击键盘按钮关闭屏幕键盘的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10513141/

相关文章:

ios - 针对大数据的 CoreData 优化

iphone - 接口(interface)xcode脚本的实现方法

ios - 使用 Xcode 8.3.3 和 Swift 3 从移动应用程序向服务器发送 NS 用户身份验证数据问题

iphone - 在应用程序启动时弹出非 Root View Controller (iOS)

iphone - 当 iPhone 中的 Appstore 上的应用程序版本更改时,sqlite 数据库更新

ios - dequeueReusableCellWithIdentifier 中的副标题

ios - 查找字符串 Swift 中完整单词的数量

xcode - 如何部署 Mac 命令行工具

Xcode 卡在索引上

xcode - 在 Swift 中将 float 显示为可变的小数位数