iOS - indexPathForRowAtPoint não retorna indexPath correto com altura de célula diferente
Eu tenho UITableView que contém muitas células. O usuário pode expandir a célula para ver mais conteúdo nesta célula, pressionando o botão de expansão nesta célula (apenas 1 célula pode expandir no tempo):
<code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if(selectedRowIndex == indexPath.row) return 205; else return 60; } </code>
No storyboard, eu arrasto UILongPressGesture no botão da célula e nomei-o como longPress (a célula é personalizada, tem 2 botões, 1 precisa reconhecer LongPressGesture, a outra expande a altura da célula):
<code>@property (retain, nonatomic) IBOutlet UILongPressGestureRecognizer *longPress; </code>
E no viewDidLoad:
<code>- (void)viewDidLoad { [longPress addTarget:self action:@selector(handleLongPress:)]; } </code>
Ele funciona perfeitamente, no entanto, quando eu uso o código a seguir para reconhecer o indexPath da célula, está errado quando uma célula é expandida:
<code>- (void)handleLongPress:(UILongPressGestureRecognizer*)sender { // Get index path slidePickerPoint = [sender locationInView:self.tableView]; NSIndexPath *indexPath= [self.tableView indexPathForRowAtPoint:slidePickerPoint]; // It's wrong when 1 cell is expand and the cell's button I hold is below the expand button } </code>
Alguém pode por favor me mostrar como obter indexPath correto quando há diferentes alturas de células?
Agradeço antecipadamente