监听键盘弹出|监听键盘弹出 iOS
//增加监听,当键盘出现或改变时收出消息
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
//增加监听,当键退出时收出消息
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
【监听键盘弹出|监听键盘弹出 iOS】//当键盘出现或改变时调用
- (void)keyboardWillShow:(NSNotification *)aNotification {
//获取键盘的高度
NSDictionary *userInfo = [aNotification userInfo];
NSValue *aValue = https://www.it610.com/article/[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardRect = [aValue CGRectValue];
int height = keyboardRect.size.height;
// 需要进行的操作
}
//当键退出时调用 - (void)keyboardWillHide:(NSNotification *)aNotification {
// 界面复原
}
推荐阅读
- EditText默认不获取焦点弹出键盘
- Quartz|Quartz 源码解析(四) —— QuartzScheduler和Listener事件监听
- vue_day05
- iOS键盘工具条自定义
- 安卓软键盘
- linux监听蒲公英线程,重启
- 20180821
- 移动端html5网站,如何设置输入框键盘的“搜索”“前往”按钮|移动端html5网站,如何设置输入框键盘的“搜索”“前往”按钮 - input type
- 软键盘搜索按钮同步搜索框
- SwiftUI|SwiftUI Button监听点击和释放消息 实现照片切换 (教程含源码 技术大全)