您的位置:首页 > 移动开发 > IOS开发

ios 动态监听键盘输入法和高度

2013-05-29 17:17 369 查看
//监听键盘高度变化
[[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);
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: