ITeye博客

iOS Keyboard 键盘高度变化 自适应

janedoneway · 2013-01-15 15:43 · iPhone · 移动开发 · Markdown

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

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。