À l'aide d'un fichier XIB pour personnalisé Tableview en-Tête de Section

Je voulais utiliser un fichier xib pour personnaliser un tableview section dans xcode (objective-C), et ici, les ar mes fichiers:

SectionHeaderView.xib est une UIView avec un 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

et dans mon 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;

}

Cela fonctionne bien jusqu'ici, cependant dès que j'ai mis XIB du propriétaire du fichier de classe personnalisée "SectionHeaderView" et connectez l'Étiquette "sectionHeader" je reçois le message d'erreur "NSUnknownKeyException". J'ai voulu relier ces pour que je puisse changer l'étiquette.texte par le code suivant avant de retourner le haeder:

header.sectionHeader.text = headerText;

Je suis à l'aide d'un scénario (xcode 4.5) pour la MasterViewController.
Serais reconnaissant de toute aide

OriginalL'auteur Ali | 2012-09-23