I have my table view and the cells within it have the UILongPressGestureRecognizer added to them. The issue is that once a cell it touched it gets highlighted, but once my long gesture starts (holding the button) the highlighting goes away. The gesture works and its still being held but its a little confusing to the user because they dont know if its still being held. How can I make the cell stay highlighted throughout the hold.
some code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
//add long press gesture for the audio AB (eventually VC and TP as well) list
//so that users can hold the cell and after 5 seconds have the dialpad for editing that entry
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleLongPress:)];
longPress.minimumPressDuration = 1;
[cell addGestureRecognizer:longPress];
}
cell.textLabel.text = [self.tableArray objectAtIndex:indexPath.row];
return cell;
}
- (void)handleLongPress:(UILongPressGestureRecognizer*)sender
{
//used to get indexPath of cell pressed
UITableViewCell *cell = (UITableViewCell *)[sender view];
//get the indexPath of cell pressed
NSIndexPath *indexPath = [self.myTableView indexPathForCell:cell];
//use the index press to figure out the proper join to hold
self.sharedJoinNumber = indexPath.row+286 ;
}
I did get this problem fixed by using
right after
- (void)handleLongPress:(UILongPressGestureRecognizer*)senderhowever now if the hold is canceled the next cell clicked needs to be double taped to be highlighted. Basically the next tap after the longpress is cancelled doesnt get noticed. but i think this is a separate questing which i will file accordingly. the above code does fix my problem