I'm Creating a custom UIView called InfoAboutBlockView, I'm adding it to my ViewController and it added correctly but when I'm pressing a button inside that custom UIView it won't fire.
I'm creating a xib file in which I design the UIView and then I create the .h and .m files
InfoAboutBlockView.h:
#import <UIKit/UIKit.h>
@interface InfoAboutBlockView : UIView
- (instancetype)init2;
@property (strong, nonatomic) IBOutlet UIView *contentView;
@end
the contentView
is the UIView linked to the .h file.
InfoAboutBlockView.m
#import "InfoAboutBlockView.h"
@implementation InfoAboutBlockView
- (instancetype)init2 {
self = [super init];
if (self) {
[self loadViewsFromBundle];
}
return self;
}
- (void)loadViewsFromBundle {
NSString *class_name = NSStringFromClass([self class]);
[[NSBundle mainBundle] loadNibNamed:class_name owner:self options:nil];
[self addSubview:self.contentView];
}
- (IBAction)startBlockButtonPressed:(id)sender {
//This Won't Fire
}
@end
The startBlockButtonPressed
is the button connected to the .m file.
I set a breakpoint at startBlockButtonPressed
but it never fires.
This is how I add the custom subview to my ViewController:
InfoAboutBlockView *infoAboutBlockView = [[InfoAboutBlockView alloc]init2];
[self.view addSubview:infoAboutBlockView];
I tried bringing it to the front using [self.view bringSubviewToFront:infoAboutBlockView];
and checked that it isn't nil
and that the button isn't nil
but it just won't fire.