相比於其他的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 //設置行高