molon / MLLabel

UILabel replacement with TextKit. Support link and expression.
MIT License
723 stars 115 forks source link

请教一下,像微信朋友圈的评论那样,不但名字可以点击,整个label也可以点击回复要怎么做 #33

Closed qiaovc closed 8 years ago

molon commented 8 years ago

@Verchen 无非就是给Label加点击事件啊。

qiaovc commented 8 years ago

@molon 给label加点击手势的话 名字的点击事件就没有了

molon commented 8 years ago

@Verchen 在点击手势delegate回调里做过滤。有方法判断是否某一点是否是在链接范围内的。

qiaovc commented 8 years ago

@molon 。。。。在哪个方法里,新人一枚,方便加个好友吗,335437639

molon commented 8 years ago

好吧,我加你。

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    //    return ![self.label linkAtPoint:[touch locationInView:self.label]];

    //如果此手势在外层的外层view的话,不方便直接定位到label的话,可以使用这种方式。
    CGPoint location = [touch locationInView:gestureRecognizer.view];
    UIView *view = [gestureRecognizer.view hitTest:location withEvent:nil];
    if ([view isKindOfClass:[MLLinkLabel class]]) {
        if ([((MLLinkLabel*)view) linkAtPoint:[touch locationInView:view]]) {
            return NO;
        }
    }

    return YES;
}

例如ListNoNibTableViewCell.m