UITableViewCell不重用代码
{
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;
}