I have a UITableView which contains names in each row alongwith images for each name. When on searching the particular name gets searched, the images are not searched for the same UITableViewCell. The image of the first row or the cell remains the same. How can I search for the images also?
I have uploaded the Images of the search issue.
[1]: https://i.stack.imgur.com/QcvtU.png“TableView “
[2]: https://i.stack.imgur.com/RmsIv.png“Search In Tableview “
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier ];
}
if(temp==1)
{
cell.textLabel.text = [newarray objectAtIndex:indexPath.row];
//cell.textLabel.text = [newarray2 objectAtIndex:indexPath.row];
}
else
{
cell.textLabel.text= [array objectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:[imagearray objectAtIndex:indexPath.row]];
}
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
return cell;
}
you have newarray mutable for the name items, you must create a newarrayimages too.
So alloc and init newarrayimages like newarray and add:
try this and let me know.
by