无标题文章

#pragmamark返回每行的单元格

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{//NSIndexPath是一个对象,记录了组和行信息NSLog(@"生成单元格(组:%i,行%i)",indexPath.section,indexPath.row);

KCContactGroup *group=_contacts[indexPath.section];

KCContact *contact=group.contacts[indexPath.row];//由于此方法调用十分频繁,cell的标示声明成静态变量有利于性能优化staticNSString *cellIdentifier=@"UITableViewCellIdentifierKey1";//首先根据标识去缓存池取UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];//如果缓存池没有到则重新创建并放到缓存池中if(!cell){

cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier];

}

cell.textLabel.text=[contact getName];

cell.detailTextLabel.text=contact.phoneNumber;

NSLog(@"cell:%@",cell);returncell;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容