博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
自定义cell
阅读量:7090 次
发布时间:2019-06-28

本文共 2114 字,大约阅读时间需要 7 分钟。

- (UITableViewCell *)tableView:(UITableView *)tableView         cellForRowAtIndexPath:(NSIndexPath *)indexPath {        // 为其定义一个标识符,在重用机制中,标识符非常重要,这是系统用来匹配table各行cell的判断标准,在以后的学习中会体会到    static NSString *identifier = @"identifier";        // 从缓存队列中取出复用的cell(重用队列中取出cell)    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];#pragma mark -- 自定义cell    UILabel *carriers; //运营商    UILabel *telPhone; //电话号码    UILabel *time; //通话时间    UILabel *date;  //通话日期        // 如果队列中cell为空,即无复用的cell,则对其进行初始化    if (cell == nil) {                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1  reuseIdentifier:identifier];                // 定义其辅助样式        cell.accessoryType      = UITableViewCellAccessoryDetailButton;                //运营商        CGRect carriersF = CGRectMake(30, 30, 80, 30);        carriers = [[UILabel alloc] initWithFrame:carriersF];        carriers.font = [UIFont systemFontOfSize:12];        [cell addSubview:carriers];        //电话号码        CGRect telPhoneF = CGRectMake(30, 8, 80, 30);        telPhone = [[UILabel alloc] initWithFrame:telPhoneF];        telPhone.font = [UIFont systemFontOfSize:16];        [cell addSubview:telPhone];        //通话时间        CGRect timeF = CGRectMake(270, 8, 80, 30);        time = [[UILabel alloc] initWithFrame:timeF];        time.font = [UIFont systemFontOfSize:16];        [cell addSubview:time];                //通话日期        CGRect dateF = CGRectMake(270, 30, 80, 30);        date = [[UILabel alloc] initWithFrame:dateF];        date.font = [UIFont systemFontOfSize:12];        [cell addSubview:date];    }        NSDate *  senddate=[NSDate date];        NSDateFormatter  *dateformatter=[[NSDateFormatter alloc] init];        [dateformatter setDateFormat:@"YYYY-MM-dd"];        NSString *  locationString=[dateformatter stringFromDate:senddate];        NSArray *array =  [self.dataSourceArray objectAtIndex:indexPath.row];        carriers.text =@"中国移动";    telPhone.text = array[0];    time.text = array[1];    date.text = locationString;    return cell;}

 

转载于:https://www.cnblogs.com/HwangKop/p/4755203.html

你可能感兴趣的文章
django模板详解(二)
查看>>
ASM概述
查看>>
手动删除数据库 oracle
查看>>
浅析ConcurrentHashMap
查看>>
html中header结构详解
查看>>
日常使用
查看>>
jQuery实现还能输入N字符
查看>>
su命令
查看>>
使用Wisdom RESTClient进行自动化测试,如何取消对返回的body内容的校验?对排除的JSON属性字段不做校验?...
查看>>
python开源项目及示例代码
查看>>
MySQL集群简介与配置详解
查看>>
linux命令:grub 文件详解及grub修复,系统常见故障修复
查看>>
RHEL7 Or CentOS7下配置aliyun-epel和fedora的EPEL源
查看>>
Oracle Database 12c新特性汇总页面
查看>>
Exchange 2016 数据库副本自动分配新功能
查看>>
解决 WP迁移后出现的404错误
查看>>
Python 学习日记第四篇 -- 函数,文件
查看>>
docker运行nginx为什么要使用 daemon off
查看>>
Linux 系统里用户管理
查看>>
上汽集团数据业务部高级总监刘峰:突破瓶颈 激发数据生产力
查看>>