G'day Folksobjets iOS null Interface Builder
Dans cette méthode ...
- (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];
}
les lignes qui agissent sur footerView
& footerText
travail, mais ceux qui agissent sur headerView
& headerText
ne sont pas. Ce screen shot montre comment j'ai des choses connectées dans IB. Les lignes debug
(script NSLog de Marcus Zarra) me disent que headerView
& headerText
sont null depuis le début & que headerText.text
est null après avoir tenté de définir le texte. Dans le fichier eader j'ai ...
@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;
Je déchire ma peau par-dessus celle-ci. J'ai vérifié & re-vérifié & échouer à voir quelque chose hors de propos, je l'ai comparé plusieurs fois avec une autre classe en utilisant une méthode similaire (mais avec des éléments à jongler dans l'en-tête) & ne peut pas voir une différence.
Quelqu'un peut-il donner des indices sur la façon dont je me trompe? Étant donné que c'est quelque chose que j'ai fait quelques fois, la familiarité a engendré la cécité.
Vive & TIA, Pedro
Vérifiez-vous votre paramètre theTitleText pour voir quelle est cette valeur? –
La première ligne de débogage fait cela & c'est le texte attendu. – Pedro