0
데이터 및 이미지가 UITableView의 셀에 있습니다. 특정 셀의 이미지를 변경하고 싶습니다. 각 셀에 코드가 있습니다.특정 셀에 대한 UITableView의 반복
셀에 대한 tableview를 반복하는 방법을 찾을 수 없습니다.
여기 내 테이블 뷰 기능의 스냅 샷입니다.
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellText = nil;
NSArray *keys = [[[self packageItems] allKeys]
sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
cellText = [keys objectAtIndex:[indexPath row]];
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
}
cell.imageView.image=[UIImage imageNamed:@"checkbox.png"];
//cell.imageView.image=[UIImage imageNamed:@"checkbox-checked.png"];
return cell;
}
내가 cell.imageView.image = 셀에 화상 변경할 다른 함수가 [있는 UIImage imageNamed를 @ '체크 박스-checked.png "];
- (void)OnAction
{
static NSString *CellIdentifier = @"Cell";
NSIndexPath *indexPath = [[NSIndexPath alloc] initWithIndex:0];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath ];
cell.imageView.image=[UIImage imageNamed:@"checkbox-checked.png"];
}
감사합니다 사랑, 내 문제가 indexToModify을 찾는 것입니다. 내 OnAction 함수에서 키를 가져오고이 키는 각 셀 키와 비교해야합니다. 일치하는 경우에만 이미지를 변경하고 싶습니다. 당신의 대답은 나에게도 도움이된다. – Krishan