SlackTextViewController
SlackTextViewController copied to clipboard
Long press on tableview seems to be in conflict with the other recognizers
When trying to register a long press gesture on the tableView in SLKTextViewController the desired method in the selector is never called. At first I thought it might be because I didn't implement the delegate as mentioned in https://github.com/slackhq/SlackTextViewController/issues/376 but it turns out that adding that delegate to my controller doesn't do anything for me.
I also tried to disable the other two gestures to no avail by using enabled=NO
.
It seems to me that UILongPressGestureRecognizer
is blocked at some level. Here is the code I am using. A long press on a table cell that uses the code below will just result in the cell being unhighlighted.
- (void)viewDidLoad {
...
longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(longPressGestureRecognized:)];
longPressGestureRecognizer.delegate = self;
self.singleTapGesture.enabled = NO;
self.verticalPanGesture.enabled = NO;
[self.tableView addGestureRecognizer:longPressGestureRecognizer];
...
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES; // NO or YES - it's always the same result
}
OTOH adding the recognizer to the UITableViewCell like in the example in https://github.com/slackhq/SlackTextViewController/blob/master/Examples/Messenger-Shared/MessageViewController.m works just fine.
This snippet looks like you're adding the long press to the tableView
, and not the cells:
[self.tableView addGestureRecognizer:longPressGestureRecognizer];
@dzenbot exactly. This works just fine in a regular UITableViewController, but for some reason doesn't in SLKTextViewController. As I mentioned in the last comment, I was able to work around it by just adding the longpress to the cell, but it was a point of confusion. It's totally possible that I might have overlooked some concept that I was not aware of here though, so the question whether that is a legitimate bug is up for debate.
Seems like a legitimate bug to me. I have the same problem as keyboardsamurai. Going to do the workaround that he posted. Cheers.
+1 to this bug. Any ETA on a fix for this?