iOS TPKeyboardAvoiding框架使用,防止键盘遮挡

论坛 期权论坛 脚本     
匿名技术用户   2021-1-1 20:15   11   0

最近了解了TPKeyboardAvoiding的使用。

一,作用:

解决文本输入时键盘遮挡输入框的问题。如果界面上有多个文本输入框,TPKeyboardAvoiding能实现屏幕自动向上滚动的功能,这样键盘就不会遮挡位置考下的输入框。

二,安装:

使用CocoaPods安装,

pod 'TPKeyboardAvoiding'

三,使用:

_myTableView = ({

TPKeyboardAvoidingTableView *tableView = [[TPKeyboardAvoidingTableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];

tableView.dataSource = self;

tableView.delegate = self;

tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

[self.view addSubview:tableView];

[tableView mas_makeConstraints:^(MASConstraintMaker *make) {

make.edges.equalTo(self.view).insets(UIEdgeInsetsMake(kSafeArea_Top, 0, 0, 0));

}];

tableView.estimatedRowHeight = 0;

tableView.estimatedSectionHeaderHeight = 0;

tableView.estimatedSectionFooterHeight = 0;

tableView;

});

和普通控件一样使用就可以了,很简单,他会自动屏幕滚动防止遮挡,现在把使用方法给大家,以后有时间研究其原理。

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP