0

I'm using GLTapLabel to display my text in my UITableView. It will have some links I can click on as GLTapLabels, but when I click those links the tableView:didSelectRowAtIndexPath: fires. So how can I detect the click action in those links?

jszumski
  • 7,430
  • 11
  • 40
  • 53
jackiviet
  • 131
  • 1
  • 10

1 Answers1

1

Implement tableView:willSelectRowAtIndexPath: and return nil for any row you don't want to be selected.

Return Value An index-path object that confirms or alters the selected row. Return an NSIndexPath object other than indexPath if you want another cell to be selected. Return nil if you don't want the row selected.

For example, to only prevent selection in the first section:

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
         return nil;
    }

    return indexPath;
}

You can also try setting exclusiveTouch on the GLTapLabel or overriding its hitTest:withEvent: as described in the answer to Why is UIView exclusiveTouch property not blocking?.

Community
  • 1
  • 1
jszumski
  • 7,430
  • 11
  • 40
  • 53
  • Thank you for a detailed answer. I gonna try your solution soon and let you know if I have another issues. – jackiviet Apr 15 '13 at 15:18
  • Hi, I try doing as your advices and it seems I cannt click links and the tableView:didSelectRowAtIndexPath: also doesnt fire. What I want is when I click outside the links, the tableView:didSelectRowAtIndexPath: will fire, and click in the links it will do something. Can u help me fix it? Thank you in advanced. – jackiviet Apr 16 '13 at 13:55