So, Im following this great tutorial at http://www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2 to get started with iOS programming.
And I decided that I would like to have custom made headers for my table, and as always I found lots of info here on stackoverflow, that I should implement the method viewForHeaderInSection in my UITableViewDelegate.
So, since I’m using storyboard I thought I’d create my own class of UITableView and then use it for my table in the storyboard.
I have also selected “MyTableView” as “Class” under “Custom Class” in the”Identity inspector” for my table.
My subclass of UITableView (MyTableView.h) looks like this:
#import <UIKit/Uikit.h>
@interface MyTableView : UITableView <UITableViewDelegate>
@end
And MyTableView.m looks like:
#import "MyTableView.h"
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.delegate = self;
}
return self;
}
// and then viewForHeaderInSection and heightForHeaderInSection is implemented below...
@end
You should be subclassing UITableViewController and not UITableView.
when adding a new file to your project (choose : Cocoa touch -> Objective-c class) you should choose subclass of “UITableViewController”
your .h file should look like this
in the .m file you should implement
viewForHeaderInsectionandheightForHeaderInSectionthen go to your storyboard and drag a “UITableViewController” from the objects library.
set the class to MyTableViewController.