[英]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;
...
}
一切都顯示為正確連接。 我已經清理了我的構建文件夾。 我已經清除了派生數據文件夾。 我什至試圖通過在 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.