键盘弹出与收起

来源:互联网 发布:行知学园高田马场地址 编辑:程序博客网 时间:2024/05/29 16:58
#pragma mark - keyBoardNotifacation- (void)registerForKeyboardNotifications{    [[NSNotificationCenter defaultCenter] addObserver:self                                             selector:@selector(keyboardWillShow:)                                                 name:UIKeyboardWillShowNotification                                               object:nil];        [[NSNotificationCenter defaultCenter] addObserver:self                                             selector:@selector(keyboardWillHide:)                                                 name:UIKeyboardWillHideNotification                                               object:nil];}- (void)keyboardWillShow:(NSNotification *)notification{    CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;        UIEdgeInsets contentInsets;    contentInsets = UIEdgeInsetsMake(0.0, 0.0, (keyboardSize.height+130), 0.0);        self.tableView.contentInset = contentInsets;}
- (void)keyboardWillHide:(NSNotification *)notification{    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 110, 0);}

0 0
原创粉丝点击