1
저는 tableview 셀을 사용하고있는 app을 만들고 있고 uitableview 셀에는 checkbox 형태의 버튼을 사용하고 있습니다. 나는 "uncheck.png"과 "tick.png"라는 두 개의 이미지를 가지고 있는데, 그 버튼을 클릭 할 때 틱은 보이지만 uncheck 이미지는 사라져 버린다. 체크하지 않은 이미지에서 그 틱 이미지를 원한다 ...! 체크 박스 아이콘이 제대로 표시되지 않습니다.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *tableviewidentifier = @"cell";
tablecellTableViewCell *cell= [self.activitiesTableView_ dequeueReusableCellWithIdentifier:tableviewidentifier];
if(cell==nil)
{
cell = [[tablecellTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:tableviewidentifier];
}
UILabel *valuedate = (UILabel *)[cell viewWithTag:11];
UILabel *msg = (UILabel *)[cell viewWithTag:12];
UILabel *date = (UILabel *)[cell viewWithTag:13];
UILabel *time = (UILabel *)[cell viewWithTag:14];
[valuedate setText:@"Demo"];
[msg setText:@"How are You?"];
[email protected]"14/07/2014";
[email protected]"A 08:16";
// [cell.textLabel setText:activityModel.userName];
valuedate.font=[UIFont fontWithName:@"SegoeUI" size:15];
msg.font=[UIFont fontWithName:@"SegoeUI-light" size:10.0];
date.font=[UIFont fontWithName:@"SegoeUI-light" size:9];
time.font=[UIFont fontWithName:@"SegoeUI-light" size:9];
if ([self.checkimageArray containsObject:[self.lblArray objectAtIndex:indexPath.row]])
{
[cell.button setImage:[UIImage imageNamed:@"tick.png"] forState:UIControlStateNormal];
//[cell.button setImage:[UIImage imageNamed:@"uncheck.png"] forState:UIControlStateNormal];
}
else
{
[cell.button setImage:[UIImage imageNamed:@"uncheck.png"] forState:UIControlStateNormal];
}
cell.button.tag=indexPath.row;
[cell.button addTarget:self action:@selector(checkButton:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
문제를 해결할 수있을 수도 있습니다
로 코드를 바꿉니다 전무
로 설정 한 하지만 첫 번째 셀에서 작동하지 않습니다. –
잘 작동하지 않습니다 ... 첫 번째 셀이 배경 이미지를 표시하지 않고 다음 셀이 배경 이미지를 표시하고 다음 셀이 선택 취소되지 않았습니다. –
셀 재사용 성 때문에이 문제가 발생할 수 있습니다. 내 대답에 주어진 편집 된 코드. – iHulk