I'm missing something important. Not exactly sure what it is.
I have a custom view subclass. I created a xib file to design its layout. I connected four buttons as outlets to the class.
#import <UIKit/UIKit.h>
@interface MCQView : UIView
@property (strong, nonatomic) IBOutlet UIButton *btn1;
@property (strong, nonatomic) IBOutlet UIButton *btn2;
@property (strong, nonatomic) IBOutlet UIButton *btn3;
@property (strong, nonatomic) IBOutlet UIButton *btn4;
I then have
#import "MCQView.h"
@implementation MCQView
@synthesize btn1,btn2,btn3,btn4;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self addSubview:[[[NSBundle mainBundle] loadNibNamed:@"MCQView" owner:self options:nil] objectAtIndex:0]];
NSLog(@"%@", btn1);
return self;
}
I then add the view to another view controller via: initWithFrame
.
When I try to log btn1, to see if it exists, it prints null. I assume that its because I haven't initialized it, but I'm not exactly sure how to do that, considering that if I create it as a new button then all of the stuff in the xib will be useless?