我有以下代码:
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];
我- (void)submitRegister;
在类标题中作为实例方法;
问题是没有触发事件,因为我的 submitRegister 实现中有 NSLog
我试过的:
1. UIButton *registerBtnTwo = [UIButton buttonWithType:UIButtonTypeCustom];
2. UIButton *registerBtnTwo = [[UIButton alloc] initWithFrame:frame];
编辑 1:我将当前视图控制器添加到我的 navigationController 中的是谁?
if ( row == kLoginRegisterIndex ) {
login = [[LoginRegisterVC alloc] init];
[self.navigationController pushViewController:login animated:YES];
}
编辑2:
UIView *registerPanel = [[UIView alloc] initWithFrame:frame];
registerPanel.backgroundColor = [UIColor colorWithPatternImage:image];
有任何想法吗?