关于UITableView的若干方法-15-05-07

 1—   self.carTableView.dataSource = self;    

          ——要设置数据源才能进行对列表相关设置。

2—-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView  

          ———设置总的有几组数据

3—-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section  

          ————设置第section组有几个数据

4—-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath   

          ——设置indexpath的数据,其中indexpath为结构体,有section和row成员

5—    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];  

6—  UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];

          ——新建类型为UITableViewCellStyleSubtitle,标识为ID的cell

7— 类型为UITableViewCellStyleSubtitle的UITableViewCell有三个成员可以进行图片,文本,详细文本的赋值。imageView——textLabel ——detailTextLabel

               UITableViewCell内部有个默认的子视图:contentView,以上均为contentview的子控件。

8—-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  

          ——当列表中某行被点击时会调用该代理方法。

9— - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView

          ——代用该方法会生成右边索引条

补充——辅助指示视图的作用是显示一个表示动作的图标,可以通过设置UITableViewCell的accessoryType来显示

          ——从缓存中取出标识为ID的UITableViewCell的内存,进行重新赋值

原文地址:https://www.cnblogs.com/tusiji7/p/4486327.html