注册键盘通知,动态读取键盘的高度
动态读取键盘的高度
- (void) registerForKeyboardNotifications
{
[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyboardWasShown:) name:UIKeyboardDidShowNotificationobject:nil];
[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyboardWasHidden:) name:UIKeyboardDidHideNotificationobject:nil];
[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyChangeFrame:) name:UIKeyboardWillChangeFrameNotificationobject:nil];
}
- (void) keyboardWasShown:(NSNotification *) notif
{
NSDictionary *info = [notif userInfo];
NSValue *value = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
CGSize keyboardSize = [value CGRectValue].size;
SJBLog(@"keyBoard:%f", keyboardSize.height); //216
self.myLabel.frame = CGRectMake(0, APPBOUND.size.height-keyboardSize.height-44-35, APPBOUND.size.width, 35);
///keyboardWasShown = YES;
}
- (void) keyboardWasHidden:(NSNotification *) notif
{
NSDictionary *info = [notif userInfo];
NSValue *value = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
CGSize keyboardSize = [value CGRectValue].size;
SJBLog(@"keyboardWasHidden keyBoard:%f", keyboardSize.height);
// keyboardWasShown = NO;
}
- (void) keyChangeFrame:(NSNotification *) notif
{
NSDictionary *info = [notif userInfo];
NSValue *value = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
CGSize keyboardSize = [value CGRectValue].size;
SJBLog(@"keyBoard:%f,,,info==%@", keyboardSize.height,info); //216
self.myLabel.frame = CGRectMake(0, APPBOUND.size.height-keyboardSize.height-44-35, APPBOUND.size.width, 35);
///keyboardWasShown = YES;
}
上一篇: lucene入门-复杂索引建立
下一篇: lucene-索引的合并
推荐阅读