简体   繁体   English

iOS空的Interface Builder对象

[英]iOS null Interface Builder objects

G'day Folks G'day民间

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. 作用于footerViewfooterText有效,但作用于headerViewheaderText行却无效。 This screen shot shows how I have things hooked up in IB. 屏幕快照显示了我如何将事情挂接到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. debug行(Marcus Zarra的NSLog脚本)告诉我, headerViewheaderText从头开始为空,并且在尝试设置文本后, headerText.text为空。 In the eader file I have... 在eader文件中,我有...

@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. 鉴于这是我做过几次的事情,p'aps的熟悉已导致失明。

Cheers & TIA, Pedro 干杯和TIA,佩德罗

In what method do you call your -(void)configureTableWithTitle: about: method? 您用什么方法调用-(void)configureTableWithTitle:about:方法? Are you sure, that it's after viewDidLoad: ? 您确定是在viewDidLoad:之后吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM