Sto provando a creare una vista personalizzata per il mio footerView UITableView che contiene un pulsante. Posso vederlo lì, ma quando lo tocco, non succede nulla ... si può vedere che cosa c'è che non va qui:UITableView footerView con pulsante, il pulsante non funziona
- (void)viewDidLoad {
[super viewDidLoad];
if(self.tableView.tableFooterView == nil) {
//allocate the view if it doesn't exist yet
UIView *footerView = [[UIView alloc] init];
//create the button
UIButton *addNewBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//the button should be as big as a table view cell
[addNewBtn setFrame:CGRectMake(0, 0, 320, [AddMerchantTVC cellHeight])];
//set title, font size and font color
[addNewBtn setTitle:@"Add New" forState:UIControlStateNormal];
[addNewBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:20]];
[addNewBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[addNewBtn addTarget:self action:@selector(addNew:) forControlEvents:UIControlEventTouchUpInside];
UIImageView *cellGradient = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellGradient.png"]];
cellGradient.frame = CGRectMake(0, 54, 320, 16);
[footerView addSubview:cellGradient];
//add the button to the view
[footerView addSubview:addNewBtn];
footerView.userInteractionEnabled = YES;
self.tableView.tableFooterView = footerView;
self.tableView.tableFooterView.userInteractionEnabled = YES;
[footerView release];
[cellGradient release];
}
- (void)addNew:(id)sender {
// This is never called
NSLog(@"Touched.");
}
E 'stato. Grazie! –
Questo ha funzionato per me quando ho implementato '- (CGFloat) tableView: (UITableView *) tableView heightForFooterInSection: (NSInteger) section; 'per specificare l'altezza del piè di pagina. –
Questo ha funzionato anche per me, grazie! –