I am trying to add a WKLongPressGestureRecognizer to cells in a WKInterfaceTable. But it does not work. The IBActions are never fired.
Is there any trick that I'm missing? Or is this simply not supported on watchOS?
I am trying to add a WKLongPressGestureRecognizer to cells in a WKInterfaceTable. But it does not work. The IBActions are never fired.
Is there any trick that I'm missing? Or is this simply not supported on watchOS?
In case it's helpful... I've been battling the same and got to: Attaching the 'Long press gesture recogniser' under 'Table' in your screenshot, rather than 'Group' and linking to an Action in the WKInterfaceController:
- (IBAction)didLongPress:(id)sender
{
if ([sender isKindOfClass:[WKLongPressGestureRecognizer class]])
{
WKLongPressGestureRecognizer * item=(WKLongPressGestureRecognizer *)sender;
CGPoint p=[item locationInObject];
NSLog(@"long press point: %f , %f. state=%d\n",p.x,p.y,[item state]);
}
}
It's not a final solution, but the action does at least get triggered. Unfortunately when triggered, it stops the didSelectRowAtIndex coming through so it's not easy to figure which row has been long-pressed. My best thought for progressing would be to use the p.y value to determine which row in the table was long-pressed on. I've been trying to figure out how to programmatically determine row heights or translate a location into an object but have so far failed, so for the moment I have given up on this functionality as I don't really want to hard-code a row-height in. But maybe it gets someone else closer to a solution, or fits a situation where row-height can be safely be hard-coded :)
Other routes I tried (and failed), but might be a starting point for others (or save some time):