[英]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.