方法1:在原来的 UIViewController 内部再添加一层 UITableViewController

代码如下 :

//
// ViewController.m
// 键盘遮挡问题
//
// Created by 思 彭 on 17/2/4.
// Copyright © 2017年 思 彭. All rights reserved.
// #import "ViewController.h"
#import "MyCell.h" static NSString *const identify = @"cell"; @interface ViewController () <UITableViewDelegate, UITableViewDataSource> @property (nonatomic, strong) UITableView *tableView; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad];
self.tableView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.view addSubview:self.tableView]; [self.tableView registerClass:[MyCell class] forCellReuseIdentifier:identify]; UITableViewController *tableViewVc = [[UITableViewController alloc]initWithStyle:UITableViewStylePlain];
tableViewVc.tableView = self.tableView;
[self addChildViewController:tableViewVc];
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return ;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { MyCell *cell = [tableView dequeueReusableCellWithIdentifier:identify forIndexPath:indexPath];
return cell;
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end

方法2:监听键盘通知,在键盘出现或消失的时候修改tableView contentInset scrollIndicatorInsets

最新文章

  1. 初识JAVA之OOP
  2. FingerGestures for Unity3D
  3. 网络拥塞控制(三) TCP拥塞控制算法
  4. Vue.2.0.5-表单控件绑定
  5. BZOJ 3207 花神的嘲讽计划Ⅰ(函数式线段树)
  6. Java知识总结--数据库
  7. 39一个可以让你受益HTML5课程
  8. Git 一些常见的命令
  9. hive的表的基本操作
  10. JavaScript事件与例子
  11. 洛谷P4180 [Beijing2010组队]次小生成树Tree(最小生成树,LCT,主席树,倍增LCA,倍增,树链剖分)
  12. How far away ? HDU - 2586 【LCA】【RMQ】【java】
  13. Ubuntu 16.04安装Docker-CE
  14. web-worker 的使用
  15. Hibernate的注解和检索
  16. Oracle 11g透明网关连接Sqlserver
  17. STL算法总览(部分)
  18. Android 开发 VectorDrawable 矢量图 (二)了解矢量图属性与绘制
  19. loj#2038. 「SHOI2015」超能粒子炮・改
  20. Java 中&gt;&gt;和&gt;&gt;&gt;的区别

热门文章

  1. Glass Carving CodeForces - 527C (线段树)
  2. java8学习之Stream实例剖析
  3. Tableau Sheet中的操作
  4. WebView net::ERR_CLEARTEXT_NOT_PERMITTED&amp;&amp;net::ERR_INTERNET_DISCONNECTED
  5. 拒绝被坑!如何用Python和数据分析鉴别刷单!?
  6. golang之 Array(数组)
  7. yaml格式介绍
  8. Qt5多线程
  9. 【NOIP2017提高A组模拟10.7】Adore
  10. nodejs之express入门