简体   繁体   中英

View outlets are nil on viewDidLoad

My files owner has 3 outlets, and all of them are nil on viewDidLoad...

__weak IBOutlet UIView *mainImagePlaceholderView;
__weak IBOutlet UILabel *mainImageLabel;
__weak IBOutlet UIView *imageFilmstripPlaceholderView;

These are located in my .m file, ...

@implementation iRpImageViewerViewController
{
    ...
    __weak IBOutlet UIView *mainImagePlaceholderView;
    __weak IBOutlet UILabel *mainImageLabel;
    __weak IBOutlet UIView *imageFilmstripPlaceholderView;
    ...
}
  • My class in question is iRpImageViewerViewController.xib
  • In IB, the 'files owner custom class' is 'iRpImageViewerViewController.m'
  • In IB, the nib 'view custom class' is UIView

Everything shows as hooked up properly. I have cleaned my build folder. I have cleared my derived data folder. I even tried to trick the views into loading by referring to them in the init method and setting their backcolor.

-(void)viewDidLoad
    {
        [super viewDidLoad];

        // Do any additional setup after loading the view from its nib.

        theMainImageGridviewControl = [[IGGridView alloc]initWithFrame:mainImagePlaceholderView.frame style:IGGridViewStyleSingleCellPaging];

        // Set additional properties to configure the grid view
        theMainImageGridviewControl.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
        theMainImageGridviewControl.selectionType = IGGridViewSelectionTypeCell;
        theMainImageGridviewControl.contentInset = UIEdgeInsetsZero;
        theMainImageGridviewControl.allowHorizontalBounce = NO;
        theMainImageGridviewControl.alwaysBounceHorizontal = NO;
        theMainImageGridviewControl.alwaysBounceVertical = NO;

        [mainImagePlaceholderView addSubview:theMainImageGridviewControl];

        // Setting a breakpoint here reveals that all the outlets are nil
        [self addAChildViewController:theFilmstripViewController toViewWithTag:imageFilmstripPlaceholderView.tag];

        [self constructAndConfigurePrimaryImageMarker];

    }

在此处输入图片说明

在此处输入图片说明

不确定您是如何创建 XIB 和视图控制器的,但是您是否尝试将以下内容添加到您为视图控制器调用的初始化程序中:

self = [super initWithNibName:@"iRpImageViewerViewController" bundle:nil];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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