UITableView以及相关类

作者: lisheng | 来源:发表于2016-03-09 12:58 被阅读52次

UITableView中数据只有行的概念,并没有列的概念,手机操作系统中显示多列是不利于操作的。

UITableView有Group和不分组的default style. group的例子: 通讯录按首字母的group等。

UITableView中每行数据都是一个UITableViewCell,在这个控件中为了显示更多的信息,iOS已经在其内部设置好了多个子控件以供开发者使用。如果我们查看UITableViewCell的声明文件可以发现在内部有一个UIView控件(contentView,作为其他元素的父控件)、两个UILable控件(textLabel、detailTextLabel)、一个UIImage控件(imageView),分别用于容器、显示内容、详情和图片。使用效果类似于微信、QQ信息列表

UITableView

UITableViewCell --->{UIView-->{UILabel(textLabel,detailTextLabel), UIImageView}

UITableViewCellStyle---> 设置Cell的类型。

数据源:

UITableViewDataSource协议,datasource对象要实现这个协议里的非Optional项。

Section: 分组.

NSIndexPath是一个结构体,记录了组和行信息。[原以为是行列信息. :( ]

UITableViewDataSource要实现的协议

#pragma mark 返回分组数

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView#pragma mark 返回每组行数

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

#pragma mark返回每行的单元格

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

//NSIndexPath是一个结构体,记录了组和行信息。indexPath.section,indexPath.row

#pragma mark 返回每组头标题名称

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

#pragma mark 返回每组尾部说明

-(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section

#pragma mark 返回每组标题索引

-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView

相关文章

  • UITableView以及相关类

    UITableView中数据只有行的概念,并没有列的概念,手机操作系统中显示多列是不利于操作的。 UITableV...

  • UI视图相关

    UI视图相关 UITableView 相关重用机制数据源同步(新闻类app, 数据删除)并发访问串行访问 时间传递...

  • 实现 UITableView 以及思考

    实现 UITableView 以及思考 实现 UITableView 以及思考

  • UITableView iOS8 侧滑删除

    刷新列表 UITableView 相关 UITableView 索引详细

  • iOS 优秀的第三方学习

    UITableView 相关 UITableView+FDTemplateLayoutCell 苹果官方开发文档 ...

  • UITableView相关

    关键词: 开发, iOS, tableView, 使用SnapKit+FDTemplateLayoutCell时c...

  • UITableView相关

    iOS开发之UITableView全面解析详细整理:UITableView优化技巧iOS 保持界面流畅的技巧

  • UITableView相关

    1、去掉UITableView上多余的分割线 设置UITableView的tableFooterView为fram...

  • UITableView 相关

    tableHeaderView 和 tableFooterView UITableView属性里的tableHe...

  • UITableView相关

    1、基础知识 样式 UITableView有两种样式(plain,grouped),其中plain为普通列表样式,...

网友评论

本文标题:UITableView以及相关类

本文链接:https://www.haomeiwen.com/subject/kpozkttx.html