UITableView初始

   近期在自学IOS,看了黑马提供的视频,讲的很好。在此做些笔记,以供以后查阅。注明了知识来源应该不算侵权吧。

一 UITableView

1,数据展示的条件

1⃣️ UITableView的所有数据都是由数据源(dataSource)提供的,所以要想在UITableView展示数据,必须设置UITableView的dataSource数据源对象

2⃣️ 要想当UITableView的dataSource对象,必须遵守UITableViewDataSource协议,实现相应的数据源方法

3⃣️ 当UITableView想要展示数据的时候,就会给数据源发送消息(调用数据源方法),UITableView会根据方法返回值决定展示怎样的数据

2,数据展示的过程

1⃣️先调用数据源的  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 方法,得知共有多少组

2⃣️然后调用数据源的 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section方法,拿到第section组一共有多少行

3⃣️最后调用数据源的- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 方法,得知第indexPath.section组第      indexPath.row行显示怎样的cell,就是内容。

补充两个方法

1⃣️第section组显示怎样的头部标题 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

 

2⃣️第section组显示怎样的尾部标题 - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section

posted on 2014-10-30 16:34  John_Swift  阅读(156)  评论(2编辑  收藏  举报