我有以下代碼:的UIButton沒有打電話給目標方法
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];
任何想法?
請給我看你分配和初始化registerPanel的代碼。這是一個UIView? – dasdom 2012-07-27 11:21:32