转自:http://blog.sina.com.cn/s/blog_7e3132ca0100wyls.html

在XCode对应头文件中修改该类所继承的父类:

在对应的.m文件中添加如下代码:

这样就在view上添加了一个tableView,但其样式是默认的,其中的内容也是空白的,而且此时是无法运行的,因为在头文件中添加了UITableViewDataSource和UITableViewDelegate两个类,所以必须设置一些自定义tableView样式的方法,下面列举了一些相关的方法:

设置Cell高度:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 设置SectionHeader高度:
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 设置SectionFooter高度:
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 设置Section数目:
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 设置SectionHeader内容:
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ 设置各个Section中的Cell个数:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 设置Cell内容:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 设置Cell行缩进量:
-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath 设置Cell被选中响应前动作(例如:可用以判断选中的Cell,来阻止其响应)
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath 设置Cell选中触发响应:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

最新文章

  1. 页面超慢,zabbix却没报警
  2. Jenkins邮件配置,实现邮件发送策略(可实现每个Job对应不同的发送邮箱)
  3. 在c或c+程序里打印调用栈。转
  4. Parse_ini_file
  5. 【C#学习笔记】文本复制到粘贴板
  6. PKUSC 模拟赛 day2 上午总结
  7. memset 初始化数组
  8. Super Jumping! Jumping! Jumping!(hdu 1087 LIS变形)
  9. 蓝桥网试题 java 入门训练 序列求和
  10. Es6 新增解构赋值
  11. Linux下实现CAD数据的导出
  12. Linux sftp 另外一台机器时,出现:receive message is too long
  13. SAP中的BRF+
  14. 理解ScheduledExecutorService中scheduleAtFixedRate和scheduleWithFixedDelay的区别
  15. Vmware workstation V2V
  16. java_ATM_GUI
  17. PHP新特性Trait
  18. [转]Docker基础-使用Dockerfile创建镜像
  19. BZOJ4249 : Walls 防壁
  20. DDD初探

热门文章

  1. ASP.NET MVC5 网站开发实践(二) Member区域 - 添加文章
  2. .NET平台开源项目速览(12)哈希算法集合类库HashLib
  3. 模板引擎Nvelocity实例
  4. Web APi之认证(Authentication)两种实现方式后续【三】(十五)
  5. ECMAScript5之Object
  6. MySQL学习笔记十二:数据备份与恢复
  7. React JS快速开始手册
  8. C# 设置word文档页面大小
  9. git配置
  10. Nancy之结合TinyFox调试备忘