在我的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");
}
但是当我单击按钮(我在表格页脚视图中添加)时,不会调用选择器方法。有谁知道可能是什么问题?
答案 0 :(得分:7)
为FooterView.Something设置正确的框架,如
UIView *footerView = [[[UIView alloc] initWithFrame:CGRectMake(10,10, 320, 60)] autorelease];