How can I do it without reloading all table?
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *header;
if(!self.searchBar)
{
self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 10, 270, kRowHeight)];
self.searchBar.delegate = self;
self.searchBar.barStyle = UISearchBarStyleDefault;
self.searchBar.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
self.searchBar.barTintColor = [UIColor clearColor];
}
if(!self.placeholderSearchBarView)
{
self.placeholderSearchBarView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 270, kSearchBarPlaceholderHeight)];
self.placeholderSearchBarView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:0.7];
}
if (self.showSearchBar)
{
for (UIView *v in self.tableView.tableHeaderView.subviews)
{
if (v.tag == 3433)
{
[v removeFromSuperview];
}
}
header = self.searchBar;
} else {
header = self.placeholderSearchBarView;
}
return header;
}