Closed ghost closed 10 years ago
I'm facing the exact same issue. Has anyone managed to fix this?
Ok so I got an answer from SO that worked for me. You have to remove the following lines from STTweetLabel.m
[super touchesBegan:touches withEvent:event];
[super touchesMoved:touches withEvent:event];
[super touchesEnded:touches withEvent:event];
The above results in the touch being passed up the responder chain where its acted upon by the tableview.
Interesting. Gonna take a look at this.
:+1:
@gituser87 That works, but it then entirely removes the ability to select a cell. I'm trying to support both behaviors. Hmmm.
Yes, fortunately I have enough space and other items in my UITableViewCell that can be selected to move to detail. The label control is always meant to launch a different functionality. Would be great to have the best of both world's though :)
Hey @SebastienThiebaud @gituser87 and @sprynmr I already solved the issue for me. Perhaps you can implement this solution into your code. All events are still forwarded, EXCEPT the case the user clicked on a hot word. For this case, the hot word handle block will be called. I did it like this:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
...
BOOL hotwordFound = NO;
for (id obj in _rangesOfHotWords) {
NSRange range = [[obj objectForKey:@"range"] rangeValue];
if (charIndex >= range.location && charIndex < range.location + range.length) {
_detectionBlock((STTweetHotWord)[[obj objectForKey:@"hotWord"] intValue], [_cleanText substringWithRange:range], [obj objectForKey:@"protocol"], range);
hotwordFound = YES;
break;
}
}
if(!hotwordFound) {
[super touchesEnded:touches withEvent:event];
}
}
Perhaps this helps a bit. And thanks for your great control ;)
@Nuker I tried this at one point. The problem is then your table view cell can be stuck highlighted because it never receives a touchedEnded
event. Are you not see in this?
@sprynmr Currently I do not have this problem because I deactivated the cell selection animation. Perhaps this is a solution (I did not try this): create a private method to determine if a hotword has been selected. Now use this method to determine if the event should be forwarded or not, just like I did above. This way all events will still be forwarded except those in which a hotword has been selected
@SebastienThiebaud I think I'll implement my proposed solution and post the results today evening (CET). As far as I can see it should work and should solve the problems ;)
@Nuker Could you please provide the whole method, because i still can't intercept the hot word calls
Hi @ll!
Sorry for the delay, but here is a fixed class. Just use this and all events will only be forwarded if NO hot word has been touched.
@SebastienThiebaud Perhaps you can use this implementation for your component?
Hi @Nuker
Thanks for your work, can you submit a pull request? Thank you.
Fixed with #106
Hi!
First of all, thanks for your great piece of code. Currently I am dealing with a strange problem: I added STTweetLabel (the latest version) to my custom table view cell. After I click on a hash tag or another keyword, the STTweetLabel block is called, but the event is also forwarded to the underlying UITableView which calls didSelectRowAtIndexPath. But I want to prevent this behavior. If the user clicks on a hashtag, the UITableView delegate shouldn't be called. Can you help me to achieve this? Thanks in advance.
Here is the code for setting the detection block:
Best regards Nekro