I am using 4 buttons with image from array like a gallery in TableView, Now i want to select image and deselect image for moving objects of array to another. Uitableview selection Working for the first time only, after moving images from one array to another section Before Reusing the cell tableview was working fine, but i have to reuse cell to avoid unnecessary making of table cell. I am generating Tag for each Button, getting the right one on click. When i add extra check image to button it just not showing properly coming to next cell randomly after Scrolling
-(void)buttonClicked:(UIButton*)sender {
tag = sender.tag;
NSLog(@"buttonClicked %i",tag);
UIButton *btn = (UIButton *)[sampleTableView viewWithTag:tag];
imageViewchk = [[UIImageView alloc] initWithFrame:CGRectMake(56,0 , 24,24)];
imageViewchk.image = [UIImage imageNamed:@"check.png"];
imageViewchk.tag=tag+10000;
imageViewchk.hidden=YES;
NSLog(@"imageViewchk Global %@ ",imageViewchk);
[btn addSubview:imageViewchk];
UIImageView *imageView = (UIImageView *)[sampleTableView viewWithTag:tag+10000];
if (tag>=6000) {
}
else{
if([selectedIndex containsObject:[deliveryArray objectAtIndex:tag]])
{
[selectedIndex removeObject:[deliveryArray objectAtIndex:tag]];
imageView.hidden=YES;
}
else {
[selectedIndex addObject:[deliveryArray objectAtIndex:tag]];
imageView.hidden=NO;
}
}
}