self.tableView.tableFooterView = self.footerButton;
- (UIButton *)footerBtn {
if (!_footerBtn) {
_footerBtn = [UIButton buttonWithType: UIButtonTypeCustom];
[_footerBtn setTitle:@"点哇啊" forState:UIControlStateNormal];
[_footerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[_footerBtn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
_footerBtn.backgroundColor = [UIColor yellowColor];
_footerBtn.frame = CGRectMake(0, 0, 300, 100);
}
return _footerBtn;
}
- (void)btnClick {
[_footerBtn removeFromSuperview];
self.isFirst = NO;
}
错就错在 removeFromSuperview 之后tableview的footerview展示不出来了
正确的操作应该是
self.tableView.tableFooterView = nil;
如果非要有需求是要用 removeFromSuperview 可以这么写
self.tableView.tableFooterView = nil;
[_footerBtn removeFromSuperview];