我在我的代码中使用自定义单元格。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"cell is called %d",indexPath.row);
static NSString *simpleTableIdentifier = @"partner";
FindPartnerCell *cell = (FindPartnerCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"FindPartner" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
FindPartnersList *list=[self.serachPartners objectAtIndex:indexPath.row];
cell.namesOfPartner.text=list.email;
cell.companys.text=list.phone;
UIButton *currentButton=[[UIButton alloc]init];
currentButton.tag=indexPath.row;
[currentButton addTarget:self action:@selector(buttonPressing:) forControlEvents:UIControlEventTouchUpInside];
currentButton.frame = CGRectMake(22, 10, 27, 23);
[currentButton setImage:[UIImage imageNamed:@"checkbox.png"] forState:UIControlStateNormal];
currentButton.userInteractionEnabled=YES;
[cell.cellsView addSubview:currentButton];
return cell;
}
当我尝试更改自定义单元格图像时。我选择了它将在
中调用的图像-(void) buttonPressing : (id) sender
{
UIButton *clicked = (UIButton *) sender;
[clicked setImage:[UIImage imageNamed:@"tab1.png"] forState:UIControlStateNormal];
}
当我选择特定单元格时,它会将图像更改为所有其他单元格。它将改变4+增量。
当我点击四次表示它会在4,8,16
中进行更改。
所以不得不说如何更改自定义单元格值。