G’day Folks
In this method…
- (void)configureTableWithTitle:(NSString *)theTitleText about:(NSString *)theAboutText
{
debug(@"configuring with headerText: %@", theTitleText);
debug(@"headerView description: %@", [headerView description]);
debug(@"headerText description: %@", [headerText description]);
CGPoint titleOrigin = headerText.frame.origin;
CGSize titleSize = headerText.frame.size;
[headerText setText:theTitleText];
debug(@"headerText: %@", [headerText text]);
CGSize newTitleSize = [theTitleText sizeWithFont:[headerText font] constrainedToSize:CGSizeMake(titleSize.width, 9999)];
[headerText setFrame:CGRectMake(titleOrigin.x, titleOrigin.y, titleSize.width, newTitleSize.height)];
int titleDelta = newTitleSize.height - titleSize.height;
CGSize titleViewSize = headerView.frame.size;
[headerView setFrame:CGRectMake(0, 0, titleViewSize.width, titleViewSize.height + titleDelta)];
[[self tableView] setTableHeaderView:headerView];
debug(@"footerView description: %@", [footerView description]);
debug(@"footerText description: %@", [footerText description]);
CGPoint aboutOrigin = footerText.frame.origin;
CGSize aboutSize = footerText.frame.size;
[footerText setText:theAboutText];
CGSize newAboutSize = [theAboutText sizeWithFont:[footerText font] constrainedToSize:CGSizeMake(aboutSize.width, 9999)];
[footerText setFrame:CGRectMake(aboutOrigin.x, aboutOrigin.y, aboutSize.width, newAboutSize.height)];
int aboutDelta = newAboutSize.height - aboutSize.height;
CGSize aboutViewSize = footerView.frame.size;
[footerView setFrame:CGRectMake(0, 0, aboutViewSize.width, aboutViewSize.height + aboutDelta)];
[[self tableView] setTableFooterView:footerView];
}
the lines that act on footerView & footerText work but those that act on headerView & headerText don’t. This screen shot shows how I have things hooked up in IB. The debug lines (Marcus Zarra’s NSLog script) tell me that headerView & headerText are null from the beginning & that headerText.text is null after attempting to set the text. In the eader file I have…
@interface MFProgramDetailView : UITableViewController <UITableViewDelegate>
{
UIView *headerView;
UIView *footerView;
UILabel *headerText;
UILabel *footerText;
UITableView *detailTable;
}
@property (nonatomic, retain) IBOutlet UIView *headerView;
@property (nonatomic, retain) IBOutlet UIView *footerView;
@property (nonatomic, retain) IBOutlet UILabel *headerText;
@property (nonatomic, retain) IBOutlet UILabel *footerText;
@property (nonatomic, retain) IBOutlet UITableView *detailTable;
I’m tearing my heair out over this one. I’ve checked & re-checked & fail to see anything out of place, I’ve compared it multiple times with another class using a similar method (but with items to juggle in the header) & can’t see a difference.
Can anyone offer any clues as to how I’m getting this wrong? Given this is something I’ve done a few times p’aps familiarity has bred blindness.
Cheers & TIA,
Pedro
In what method do you call your -(void)configureTableWithTitle: about: method?
Are you sure, that it’s after viewDidLoad: ?