我的问题是我的法典:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UIImageView *tickImg = [[UIImageView alloc]init];
tickImg.frame = CGRectMake(260, 28, 30, 30);
NSInteger rowNum;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
if(searching)
{
cell.textLabel.text = [copyListOfItems objectAtIndex:indexPath.row];
[cell.imageView setImageWithURL:[NSURL URLWithString:[tempArr objectAtIndex:indexPath.row]]
placeholderImage:[UIImage imageNamed:@"defaultPerson.png"]];
}else
{
for (int i=0; i<[alertArray count]; i++) {
NSString *temp = [NSString stringWithFormat:@"%@",[alertArray objectAtIndex:i]];
if ([[friendsID objectAtIndex:indexPath.row] isEqualToString:temp]) {
rowNum = indexPath.row;
NSLog(@"Row: %d",rowNum);
}
}
if (rowNum == indexPath.row) {
tickImg.image = [UIImage imageNamed:@"tick.png"];
[cell.contentView addSubview:tickImg];
}
[cell.imageView setImageWithURL:[NSURL URLWithString:[friendsImage objectAtIndex:indexPath.row]]
placeholderImage:[UIImage imageNamed:@"defaultPerson.png"]];
cell.textLabel.text = [friendsName objectAtIndex:indexPath.row];
}
return cell;
}
Here I have two arrays, one is friendsID and the other is alertArray. I have loaded the friendsID to the tableview. And in the alertArray I have some IDs, I need to show a tick mark in the row when friendsID in a row contains alertArray. I have tried with above code but not working. Please share your ideas. Thanks.