博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UITableViewCell不重用代码
阅读量:5094 次
发布时间:2019-06-13

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

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

{

    NSString *CellIdentifier = [NSString stringWithFormat:@"Cell%d%d", indexPath.section, indexPath.row];//关键

    UITableViewCell *cell = [self.tbSalary dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell==nil)

    {

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

        

        switch (indexPath.row)

        {

            case 0:

                cell.textLabel.text = @"我有工作经验";

                UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

                button.frame = CGRectMake(0, 7, 30, 30);

                [button setImage:[UIImage imageNamed:@"select_icon.png"] forState:UIControlStateNormal];

                [button addTarget:self action:@selector(buttonOkClick:) forControlEvents:UIControlEventTouchUpInside];

                cell.accessoryView = button;

                cell.selectionStyle = UITableViewCellSelectionStyleNone;

                break;

            case 1:

                cell.textLabel.text = @"地区:";

                cell.detailTextLabel.text = @"请选择地区";

                cell.detailTextLabel.textColor = [UIColor grayColor];

                UIImageView *accessoryImg1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 15, 10, 14)];

                accessoryImg1.image = [UIImage imageNamed:@"accessoryArrow.png"];

                cell.accessoryView = accessoryImg1;

                [accessoryImg1 release];

                self.regionCell = cell;

                break;

            case 2:

                cell.textLabel.text = @"行业:";

                cell.detailTextLabel.text = @"请选择行业";

                cell.detailTextLabel.textColor = [UIColor grayColor];

                UIImageView *accessoryImg2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 15, 10, 14)];

                accessoryImg2.image = [UIImage imageNamed:@"accessoryArrow.png"];

                cell.accessoryView = accessoryImg2;

                [accessoryImg2 release];

                self.industryCell = cell;

                break;

            case 3:

                cell.textLabel.text = @"企业性质:";

                cell.detailTextLabel.text = @"请选择企业性质";

                cell.detailTextLabel.textColor = [UIColor grayColor];

                UIImageView *accessoryImg3 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 15, 10, 14)];

                accessoryImg3.image = [UIImage imageNamed:@"accessoryArrow.png"];

                cell.accessoryView = accessoryImg3;

                [accessoryImg3 release];

                self.characterCell = cell;

                break;

            case 4:

                cell.textLabel.text = @"职位类别:";

                cell.detailTextLabel.text = @"请选择职位类别";

                cell.detailTextLabel.textColor = [UIColor grayColor];

                UIImageView *accessoryImg4 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 15, 10, 14)];

                accessoryImg4.image = [UIImage imageNamed:@"accessoryArrow.png"];

                cell.accessoryView = accessoryImg4;

                [accessoryImg4 release];

                

                self.categoryCell = cell;

                break;

            case 5:

                cell.textLabel.text = @"职位级别:";

                cell.detailTextLabel.text = @"请选择职位级别";

                cell.detailTextLabel.textColor = [UIColor grayColor];

                UIImageView *accessoryImg5 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 15, 10, 14)];

                accessoryImg5.image = [UIImage imageNamed:@"accessoryArrow.png"];

                cell.accessoryView = accessoryImg5;

                [accessoryImg5 release];

                self.rankCell = cell;

                break;

            case 6:

                cell.textLabel.text = @"期望月薪:";

                UITextField *tfSalary = [[UITextField alloc]initWithFrame:CGRectMake(100, 7, 190, 30)];

                tfSalary.delegate = self;

                tfSalary.keyboardType = UIKeyboardTypeNumbersAndPunctuation;

                tfSalary.textAlignment = NSTextAlignmentCenter;

                tfSalary.placeholder = @"请点击输入";

                tfSalary.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

                tfSalary.clearButtonMode = UITextFieldViewModeWhileEditing; 

                tfSalary.borderStyle = UITextBorderStyleRoundedRect;

                [cell.contentView addSubview:tfSalary];

                self.salaryTextField = tfSalary;

                [tfSalary release];

                self.salaryCell = cell;

                cell.selectionStyle = UITableViewCellSelectionStyleNone;

                break;

            default:

                break;

        }

    }

    

        

    return cell;

    

    

    

    

}

转载于:https://www.cnblogs.com/tanwen1989/p/3600514.html

你可能感兴趣的文章
sublime 配置java运行环境
查看>>
在centos上开关tomcat
查看>>
无人值守安装linux系统
查看>>
jQuery应用 代码片段
查看>>
黑马程序员——2 注释
查看>>
转化课-计算机基础及上网过程
查看>>
android dialog使用自定义布局 设置窗体大小位置
查看>>
ionic2+ 基础
查看>>
互联网模式下我们更加应该“专注”
查看>>
myeclipse集成jdk、tomcat8、maven、svn
查看>>
查询消除重复行
查看>>
Win 10 文件浏览器无法打开
查看>>
[leetcode]Minimum Path Sum
查看>>
内存管理 浅析 内存管理/内存优化技巧
查看>>
【BZOJ 5222】[Lydsy2017省队十连测]怪题
查看>>
Java跟Javac,package与import
查看>>
Json格式的字符串转换为正常显示的日期格式
查看>>
[转]使用 Razor 进行递归操作
查看>>
[转]Android xxx is not translated in yyy, zzz 的解决方法
查看>>
docker入门
查看>>