1.首先谒出,Controller需要實(shí)現(xiàn)兩個(gè)delegate,分別是UITableViewDelegate和UITableViewDataSource
2.UITableView對(duì)象的delegate需要設(shè)置為self.
3.實(shí)現(xiàn)這些delegate的一些方法
(1)-(NSInteger)numberOfSetctionsInTableView:(UITableView *)tableView;這個(gè)方法返回tableview有多少個(gè)section
(2)-(NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section;這個(gè)方法返回對(duì)應(yīng)的section有多少個(gè)元素,也就是多少行
(3)-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndePath:(NSIndexPath *)indexPath;這個(gè)方法返回制定的row的高度邻奠。
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;這個(gè)方法返回指定的section和header view的高度笤喳。
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSIteger)section;這個(gè)方法返回指定的section和footer view的高度;
(4)-(UITableViewCell *)tableView:(UITableView *)tableViewcellForRowAtIndexPath:(NSIndexPath *)indexPath;
返回指定的row的cell.這個(gè)地方很多人說比較關(guān)鍵碌宴,一般如何制定各種個(gè)性化的cell元素莉测。