I tried to implement the
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
to get the text label of the
You can get the default UITableView section headers by implementing the following methods in your tableview class:
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 22; //returning 0 hides section headers
}
This might be particularly useful if you use a UISearchDisplayController in your app, where you want the search results to be displayed in a simple UITableViewStylePlain
fashion instead of, let's say, the UITableViewStyleGrouped
of your customized main tableview. You could then implement something like this:
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if ([self.searchDisplayController.searchBar isFirstResponder]) return nil;
//create and return your custom UIView here
}