Hi, I want to hide custom button present in tableview cell for a specific condition.
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(isDisplayMapbutton==YES)
{
UIView* buttonView1 = [[UIView alloc] init];
mapBtn= [[MyCustomButton alloc] initWithIndexPath:indexPath];
CGRect imageFrame1 = CGRectMake(0,2.0,30,30);
[buttonView1 setFrame: CGRectMake(230,3.0,30,30 ) ];
[mapBtn setFrame:imageFrame1];
[mapBtn setBackgroundImage: [UIImage imageNamed:@"Map.png"] forState:UIControlStateNormal];
[mapBtn addTarget:self action:@selector(DisplayMap:)forControlEvents:UIControlEventTouchUpInside];
[buttonView1 addSubview:mapBtn];
[cell.contentView addSubview:buttonView1];
[buttonView1 release];
[mapBtn release];
}
else
{
}
return cell;
}
-(void)toggleMove
{
if(isMove==YES)
{
isDisplayMapbutton =NO;
isMove=NO;
//mapBtn.hidden=YES;
[self getToolbar];
}
else
{
isDisplayMapbutton =YES;
isMove=YES;
//mapBtn.hidden=NO;
[self getToolbar];
}
[tableView reloadData];
[self.tableView setEditing:!self.tableView.editing animated:YES];
}
If I use the above method ,[self.tableView setEditing:!self.tableView.editing animated:YES];
the cell will be compressed. then map btn is moving to the end of cell. HOW to hide this Map
button when we call the above method