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