2011-11-18 49 views
4

在我viewDidLoad中,我寫了這個代碼:的UIButton在tableFooterView不響應點擊事件

UIView *footerView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];   
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
btn.frame = CGRectMake(10,10, 300, 40); 
[btn setTitle:@"Select" forState:UIControlStateNormal]; 
[btn addTarget:self action:@selector(onClickSelect:) forControlEvents:UIControlEventTouchUpInside]; 
[footerView addSubview:btn]; 

myTableView.tableFooterView = footerView; 

和我選擇的方法是:

- (void) onClickSelect: (UIButton*) sender 
{ 
NSLog(@"selext"); 
} 

但是當我點擊按鈕(這是我已添加在表格頁腳視圖中),選擇器方法不會被調用。有誰知道可能是什麼問題?

回答

7

設置正確的框架FooterView.Something像

UIView *footerView = [[[UIView alloc] initWithFrame:CGRectMake(10,10, 320, 60)] autorelease]; 
+1

雅,得到了它。非常感謝。還有一件事,你的名字(EXE_BAD_ACCESS)太好了。 :):D – anshul

+0

@anshul謝謝:) –