UITableView

什么是UITableView

在众多移动应用中,能看到各式各样的列表数据性能

 

在iOS中,要实现展现列表数据,最经常使用的作法就是使用UITableView
UITableView继承自UIScrollView,所以支持垂直滚动,并且性能极佳spa

 

UITableView的两种样式

 

如何展现数据

UITableView须要一个数据源(dataSource)来显示数据3d

UITableView会向数据源查询一共有多少行数据以及每一行显示什么数据等对象

没有设置数据源的UITableView只是个空壳blog

凡是遵照UITableViewDataSource协议的OC对象,均可以是UITableView的数据源继承

 

tableView和数据源

 

tableView展现数据的过程

1.调用数据源的下面方法得知一共有多少组数据
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;io

2.调用数据源的下面方法得知每一组有多少行数据
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;table

3.调用数据源的下面方法得知每一行显示什么内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;方法

相关文章
相关标签/搜索