`
janedoneway
  • 浏览: 569504 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

iOS Keyboard 键盘高度变化 自适应

阅读更多

[[NSNotificationCenter defaultCenter] addObserver:self

                                             selector:@selector(keyboardWillShow:)

                                                 name:UIKeyboardWillShowNotification object:nil];

    

    [[NSNotificationCenter defaultCenter] addObserver:self

                                             selector:@selector(keyboardDidShow:)

                                                 name:UIKeyboardDidShowNotification object:nil];

    

    

    

    [[NSNotificationCenter defaultCenter] addObserver:self

                                             selector:@selector(keyboardWillHide:)

                                                 name:UIKeyboardWillHideNotification object:nil];

 

 

#pragma mark - 

 

- (void)keyboardWillShow:(NSNotification*)aNotification

{

    XuChiLog(@"%@", NSStringFromSelector(_cmd));

    

    NSDictionary* info = [aNotification userInfo];

    CGSize bkbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;

    CGSize ekbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;

    XuChiLog(@"beginkeyBoard Size: %@", NSStringFromCGSize(bkbSize));

    XuChiLog(@"  endkeyBoard Size: %@", NSStringFromCGSize(ekbSize));

}

 

- (void)keyboardWillHide:(NSNotification*)aNotification

{

    XuChiLog(@"%@", NSStringFromSelector(_cmd));

    

    NSDictionary* info = [aNotification userInfo];

    CGSize bkbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;

    CGSize ekbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;

    XuChiLog(@"beginkeyBoard Size: %@", NSStringFromCGSize(bkbSize));

    XuChiLog(@"  endkeyBoard Size: %@", NSStringFromCGSize(ekbSize));

}

 

- (void)keyboardDidShow:(NSNotification*)aNotification

{

    XuChiLog(@"%@", NSStringFromSelector(_cmd));

    

    NSDictionary* info = [aNotification userInfo];

    CGSize bkbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;

    CGSize ekbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;

    XuChiLog(@"beginkeyBoard Size: %@", NSStringFromCGSize(bkbSize));

    XuChiLog(@"  endkeyBoard Size: %@", NSStringFromCGSize(ekbSize));

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics