Reputation: 2610
I am trying to implement a custom view ( C# Custom UserControl equivalent )
Use-case:
I was expecting Xib file A elements to be rendered within Xib file B, however, The UI wasn't presented although all IBOutlets were properly associated, and 'awakeFromNib' was called.
What am I doing wrong here ?
The following is the code for the cusom XiB based ~control~ ( which is referred to by another control/view of a different XiB)
@interface SeriesView ()
@property (strong, atomic, readonly) MediaViewer* mediaViewer;
- (void) OnInitialize;
- (void) awakeFromNib;
@end
@implementation SeriesView
@synthesize mediaViewer = _mediaViewer;
@synthesize image = _image;
@synthesize scroll = _scroll;
- (id)initWithFrame:(CGRect)frame
{
if(nil == (self = [super initWithFrame:frame]))
return nil;
[[NSBundle mainBundle] loadNibNamed:@"SeriesView" owner:self options:nil];
return self;
}
- (id)initWithCoder:(NSCoder*)aDecoder
{
if(nil == (self = [super initWithCoder:aDecoder]))
return nil;
[[NSBundle mainBundle] loadNibNamed:@"SeriesView" owner:self options:nil];
return self;
}
- (void) OnInitialize
{
_mediaViewer = [[MediaViewer alloc] init];
_image.hidden= NO;
}
- (void)awakeFromNib
{
[super awakeFromNib];
[self OnInitialize];
}
@end
Upvotes: 0
Views: 3565
Reputation: 2610
Per: UIView and initWithFrame and a NIB file. How can i get the NIB file loaded?
The only part missing was
Upvotes: 2