how to change the content of table footer view while running
I want to toggle the buttons in viewForFooterInsection
i.e call the
function again on button click.
I want to toggle the buttons in viewForFooterInsection
i.e call the
Code:
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
Code:
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
if(footerView == nil) {
//allocate the view if it doesn't exist yet
footerView = [[UIView alloc] init];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
if (!favourite) {
[button setTitle:@"Add to Favorites" forState:UIControlStateNormal];
[button addTarget:self action:@selector(addFav:) forControlEvents:UIControlEventTouchUpInside];
favourite=1;
[tbldetail reloadData];
}
else {
[button setTitle:@"Remove From Favorites" forState:UIControlStateNormal];
[button addTarget:self action:@selector(removeFav:) forControlEvents:UIControlEventTouchUpInside];
favourite=0;
}
[footerView addSubview:button];
}
return footerView;
}