DCHideableSectionViewController 0.1

DCHideableSectionViewController 0.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.


Downloads

Total5
Week0
Month0

Installs

Apps1
powered by Segment

GitHub

Stars0
Watchers1
Forks0
Issues0
Contributors0
Pull Requests0

Code

Files2
LOCLines of Code 59


  • By
  • Dan Cohn

A UITableViewController subclass that can hide sections of a grouped table without displaying random padding where the section should be.

Usage

First, make your UITableViewController a subclass of DCHideableSectionViewController.

#import <UIKit/UIKit.h>
#import "DCHideableSectionViewController.h"

@interface DCMainTableViewController : DCHideableSectionViewController

@end

Next, in your UITableViewController's viewDidLoad:, set the two properties of the DCHideableSectionViewController that define the height of the header and footer views.

    self.headerViewHeight = 33.0f;
    self.footerViewHeight = 0.0f;

That's it!

If you wish to use -tableView:viewForHeaderInSection: or -tableView:viewForFooterInSection: instead of -tableView:titleForHeaderInSection: or -tableView:titleForFooterInSection:, then you must first call the super class's method. If the super class does not return nil, simply return the view returned. Otherwise, you are free to return any view you like.

For example:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view = [super tableView:tableView viewForHeaderInSection:section];

    if ( view == nil )
    {
        view = [self headerViewForSection:section];
    }

    return view;
}