预习

2016-02-21  本文已影响21人  画个完美句号

1.首先,Controller需要实现两个delegate,分别是UITableViewDelegate和UITableViewDataSource

2.UITableView对象的delegate需要设置为self.

3.实现这些delegate的一些方法

(1)-(NSInteger)numberOfSetctionsInTableView:(UITableView *)tableView;这个方法返回tableview有多少个section

(2)-(NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section;这个方法返回对应的section有多少个元素,也就是多少行

(3)-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndePath:(NSIndexPath *)indexPath;这个方法返回制定的row的高度。

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;这个方法返回指定的section和header view的高度。

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSIteger)section;这个方法返回指定的section和footer view的高度;

(4)-(UITableViewCell *)tableView:(UITableView *)tableViewcellForRowAtIndexPath:(NSIndexPath *)indexPath;

返回指定的row的cell.这个地方很多人说比较关键,一般如何制定各种个性化的cell元素。

上一篇 下一篇

猜你喜欢

热点阅读