tableFooterView中的UIButton没有响应click事件

时间:2011-11-18 06:25:07

标签: iphone objective-c ios

在我的viewDidLoad中,我编写了这段代码:

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");
 }

但是当我单击按钮(我在表格页脚视图中添加)时,不会调用选择器方法。有谁知道可能是什么问题?

1 个答案:

答案 0 :(得分:7)

为FooterView.Something设置正确的框架,如

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