键盘view 上移

来源:互联网 发布:异构系统数据集成 编辑:程序博客网 时间:2024/05/16 07:21


注册通知

-(void)initNotiy{

    

    [[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyboardWillChangeFrame1:)name:UIKeyboardWillChangeFrameNotificationobject:nil];//在这里注册通知

    [[NSNotificationCenterdefaultCenter] addObserver:self

                                             selector:@selector(keyboardWillBeHidden1:)

                                                 name:UIKeyboardWillHideNotificationobject:nil];

    

    

}




#pragma mark-notif

- (void)keyboardWillChangeFrame1:(NSNotification *)notification

{

    

    [UIViewanimateWithDuration:0.3animations:^{

        CGRect rect =_tableView.frame;

        rect.origin.y =64;

        rect.size.height =self.view.frame.size.height - 64-226-60;

        _tableView.frame = rect;

    }];

    

}



-(void)keyboardWillBeHidden1:(NSNotification*)aNotification


{   [self.viewendEditing:YES];

    

    CGRect rect =_tableView.frame;

    rect.origin.y =64;

    rect.size.height =self.view.frame.size.height-64-60 ;

    _tableView.frame = rect;

    [self.tableViewendEditing:YES];

    

}

-(void)dealloc{

    

    [[NSNotificationCenterdefaultCenter]removeObserver:self];

    

}

0 0
原创粉丝点击