La méthode sectionHeaderTapped
doit avoir l'une des signatures suivantes:
- (void)sectionHeaderTapped:(UITapGestureRecognizer *)sender;
- (void)sectionHeaderTapped;
Vous devez trouver la cellule qui a été exploité en utilisant les coordonnées du robinet.
-(void)sectionHeaderTapped:(UITapGestureRecognizer *)gestureRecognizer
{
CGPoint tapLocation = [gestureRecognizer locationInView:self.tableView];
NSIndexPath *tapIndexPath = [self.tableView indexPathForRowAtPoint:tapLocation];
UITableViewCell* tappedCell = [self.tableView cellForRowAtIndexPath:tapIndexPath];
}
Vous pouvez probablement obtenir l'en-tête de section en utilisant cette méthode. Mais il peut être plus facile d'attacher un reconnaisseur de gestes différent à chaque en-tête de section.
- (UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section
{
// ...
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(sectionHeaderTapped:)];
[headerView addGestureRecognizer:tapGesture];
return headerView;
}
Et puis
-(void)sectionHeaderTapped:(UITapGestureRecognizer *)gestureRecognizer
{
UIView *headerView = gestureRecognizer.view;
// ...
}
oui j'ai utilisé différents gestes pour chaque section, pas la meilleure façon, mais plus simple ... Merci –
préfet répondre .... merci .. –