Używanie pliku XIB dla niestandardowego nagłówka sekcji widoku tabeli
Chciałem użyć pliku xib, aby dostosować sekcję tableview w xcode (cel C), a tutaj moje pliki:
SectionHeaderView.xib to UIView z 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
iw moim 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;
}
Działa dobrze, dopóki tutaj, jak tylko ustawię niestandardową klasę właściciela pliku XIB na „SectionHeaderView” i podłączę Etykietę do „sectionHeader”, otrzymam błąd „NSUnknownKeyException”. Chciałem je połączyć, abym mógł zmienić etykietę.tekst za pomocą następującego kodu przed zwróceniem haeder:
header.sectionHeader.text = headerText;
Używam storyboardu (xcode 4.5) dla MasterViewController. Byłbym wdzięczny za każdą pomoc