I wanted to use the xib file to configure the tableview section in xcode (target C), and here ar my files:
SectionHeaderView.xib is a UIView with UILabel
SectionHeaderView.m
#import "SectionHeaderView.h"
@implementation SectionHeaderView
@synthesize sectionHeader;
@end
SectionHeaderView.h
#import <UIKit/UIKit.h>
@interface SectionHeaderView : UIView
{
IBOutlet UILabel *sectionHeader;
}
@property (nonatomic, strong) IBOutlet UILabel *sectionHeader;
@end
and in my MasterViewController.m
#import "SectionHeaderView.h"
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
SectionHeaderView *header = [[[NSBundle mainBundle] loadNibNamed:@"SectionHeaderView" owner:self options:nil] objectAtIndex:0];
return header;
}
It has been working fine so far, however, as soon as I set my own class of the XIB file owner to "SectionHeaderView" and connected the shortcut to "sectionHeader", I will get the error "NSUnknownKeyException". I wanted to link them so that I could change label.text with the following code before returning haeder:
header.sectionHeader.text = headerText;
I am using a storyboard (xcode 4.5) for MasterViewController. Would thank for any help