//监听键盘高度变化
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasChange:) name:UIKeyboardDidChangeFrameNotification object:nil];
- (void)keyboardWasChange:(NSNotification *)aNotification {
NSLog(@"Keyboard change");
NSString *str=[[UITextInputMode currentInputMode] primaryLanguage];
NSLog(@"shurufa--------------%@",str);
// if ([str isEqualToString:@"zh-Hans"]) {
// ReplayView.frame = CGRectMake(0, HEIGHT.height-216-125, 320, 45);
// }else
// {
// ReplayView.frame = CGRectMake(0, HEIGHT.height-216-89, 320, 45);
//
//
// }
NSDictionary *info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
// CGRect frame = self.search.frame;
if (kbSize.height == 216) {
NSLog(@"english");
ReplayView.frame = CGRectMake(0, HEIGHT.height-216-89, 320, 45);
}
else if(kbSize.height == 252){
NSLog(@"中文");
ReplayView.frame = CGRectMake(0, HEIGHT.height-216-125, 320, 45);
}
}
本文介绍了一种在iOS应用中实现键盘高度变化监听的方法,并根据键盘的不同高度调整UI布局,确保输入框位置正确显示。文章详细展示了如何通过UIKeyboardDidChangeFrameNotification通知来获取键盘的高度并据此调整视图的位置。
524

被折叠的 条评论
为什么被折叠?



