Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

AbhishekApple

macrumors member
Original poster
Aug 5, 2010
86
0
how to change the content of table footer view while running

I want to toggle the buttons in viewForFooterInsection

i.e call the

Code:
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
function again on button click.

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;
}
 
You just need to keep a reference to the view object that you put in the footer. Then when the button gets pressed call a selector that will change the contents of the view, just like you've done. Finally call "setNeedsDisplay" on the view. That way the view will be re-drawn with your changes.
 
You just need to keep a reference to the view object that you put in the footer. Then when the button gets pressed call a selector that will change the contents of the view, just like you've done. Finally call "setNeedsDisplay" on the view. That way the view will be re-drawn with your changes.

"setNeedsDisplay"....
Thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.