Krelborn / KILabel

A simple to use drop in replacement for UILabel for iOS 7 and above that highlights links such as URLs, twitter style usernames and hashtags and makes them touchable.
MIT License
470 stars 132 forks source link

indexPath in didSelectRowAtIndexPath #30

Open nyeu opened 9 years ago

nyeu commented 9 years ago

I have a tableview where cells display a KILabel, when I tapped a cell (not the kilabel link), I get the wrong indexpath, I get the previous indexPath selected. If I remove the kilabel, everything works like a charm.

nyeu commented 9 years ago

The way to "solve" the issue is adding [tableView reloadData] at the end of didSelectRowAtIndexPath.

Krelborn commented 9 years ago

That doesn't sound right. You really don't want to be reloading the table data after making a selection.

Have you looked at the demo project to see how to use it in a table. I can't imagine why using KILabel would affect selection of table cells.

nyeu commented 9 years ago

Yes, I know it doesn't sound right but it was the only way to get KILabel working. I looked at the demo project and all the examples available and all looks right. The thing is, if it was my mistake, why with the reloadData worked? It's a weird thing.

vgolovnev commented 9 years ago

I have exactly the same problem. It seems like a bug.

dayj commented 8 years ago

I ran into this same issue. It has to do with the way touchesBegan/Moved/Ended/Cancelled have been implemented. I was able to resolve the issue by using a UITapGestureRecognizer in lieu of overriding the touch event methods.

fealonelei commented 8 years ago

@nyeu @vgolovnev @Dayj
in * - (void)touchesEnded:(NSSet _)touches withEvent:(UIEvent )event *_ method , line 705, perhaps, just comment out [super touchesBegan:touches withEvent:event]; or remove it. It will fix the problem and didSelectRowAtIndexPath works happy again.

LinkRober commented 8 years ago

Thanks @dayj