黑馬程序員-6.UITableView

相比於其他的View,UITableView算是用的很廣的一個,和UITableView配合使用的是Cell,在程序中可以自定Cell,包括內容樣式等


UITableView需要一個數據源(dataSource)

<UITableViewDataSource>  在ViewController中聲明

做tableView的時候,需要讓控制器充當代理的角色

在控制器中調用方法對tableView進行操作

常用方法:

-(NSInterger)numberOfSectionsInTableView  //設置組數


-(NSInterger)numberOfRowsInSection  //設置每組中的行數

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath   //
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section    //設置section組顯示怎樣的頭部標題
-(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section  //設置section組顯示怎樣的尾部標題
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath  //設置行高


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章