-
- - (void)regNotification
- {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
- }
- - (void)unregNotification
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
- }
- #pragma mark - notification handler
- - (void)keyboardWillChangeFrame:(NSNotification *)notification
- {
- NSDictionary *info = [notification userInfo];
- CGFloat duration = [[info objectForKey:UIKeyboardAnimationDur
[ios] 适应键盘高度变化
最新推荐文章于 2016-10-24 09:56:11 发布
该博客介绍了如何在iOS应用中监听并处理键盘高度变化,以确保输入字段和按钮等UI元素能适应键盘弹出时的位置调整。通过注册和移除`UIKeyboardWillChangeFrameNotification`通知,获取键盘动画持续时间和结束时的键盘位置,进而计算出Y轴偏移量,最终使用动画平滑地更新输入字段和更多选项按钮的frame。
摘要由CSDN通过智能技术生成