GLTapLabel Inside UITableView

不羁的心 提交于 2019-12-12 03:57:24

问题


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?


回答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?.



来源:https://stackoverflow.com/questions/15764931/gltaplabel-inside-uitableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!