UIButton in tableFooterView not responding to click event

In my view of DidLoad, I wrote this code:

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; 

and my selection method:

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

but when I click the button (which I added as a table footer), the selection method is not called. Does anyone know what could be the problem?

+4
source share
1 answer

Set the correct frame for FooterView. Sort of

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

Source: https://habr.com/ru/post/1381841/


All Articles