ios 动态监听键盘输入法和高度
//监听键盘高度变化
[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyboardWasChange:) name:UIKeyboardDidChangeFrameNotificationobject:nil];
- (void)keyboardWasChange:(NSNotification *)aNotification {
NSLog(@"Keyboard change");
NSString *str=[[UITextInputModecurrentInputMode] 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);
}
}
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步