I have the following code:
UIImage *registerImg = [UIImage imageNamed:@"register_button_normal"];
CGFloat registerOffsetX = (view.frame.size.width - registerImg.size.width) / 2;
UIButton *registerBtnTwo = [[UIButton alloc] init];
registerBtnTwo.frame = CGRectMake(registerOffsetX, 111, registerImg.size.width, registerImg.size.height);
[registerBtnTwo setBackgroundImage:registerImg forState:UIControlStateNormal];
[registerBtnTwo addTarget:self action:@selector(submitRegister) forControlEvents:UIControlEventTouchUpInside];
[registerPanel addSubview:registerBtnTwo];
[registerBtnTwo release];
I have - (void)submitRegister; in class headers as instance method;
The problem is event isn’t fired because i have NSLog in my submitRegister implementation
What i’ve tried:
1. UIButton *registerBtnTwo = [UIButton buttonWithType:UIButtonTypeCustom];
2. UIButton *registerBtnTwo = [[UIButton alloc] initWithFrame:frame];
EDIT 1: Who i add the current View Controller to my navigationController ?
if ( row == kLoginRegisterIndex ) {
login = [[LoginRegisterVC alloc] init];
[self.navigationController pushViewController:login animated:YES];
}
EDIT 2:
UIView *registerPanel = [[UIView alloc] initWithFrame:frame];
registerPanel.backgroundColor = [UIColor colorWithPatternImage:image];
Any ideas?
The problem was that parent view was UIImageView which by default have userInteractionEnabled = NO;