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

扫描二维码关注公众号,回复: 726727 查看本文章

                                             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));

}

猜你喜欢

转载自janedoneway.iteye.com/blog/1770192