簡體   English   中英

viewDidLoad 上的視圖插座為零

[英]View outlets are nil on viewDidLoad

我的文件所有者有 3 個網點,所有這些網點在 viewDidLoad 上都為零...

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

這些位於我的 .m 文件中,...

@implementation iRpImageViewerViewController
{
    ...
    __weak IBOutlet UIView *mainImagePlaceholderView;
    __weak IBOutlet UILabel *mainImageLabel;
    __weak IBOutlet UIView *imageFilmstripPlaceholderView;
    ...
}
  • 我有問題的課程是 iRpImageViewerViewController.xib
  • 在 IB 中,“文件所有者自定義類”是“iRpImageViewerViewController.m”
  • 在 IB 中,筆尖“視圖自定義類”是 UIView

一切都顯示為正確連接。 我已經清理了我的構建文件夾。 我已經清除了派生數據文件夾。 我什至試圖通過在 init 方法中引用它們並設置它們的背景色來欺騙視圖加載。

-(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];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM