Ios 指定的HighlightLabel在UITable视图中工作不正常?

Ios 指定的HighlightLabel在UITable视图中工作不正常?,ios,iphone,uitableview,label,uilabel,Ios,Iphone,Uitableview,Label,Uilabel,我使用了一个指定的HighlightLabel来显示hashTag和@title name clickable,但是一个指定的HighlightLabel可以在uitable视图中正常工作。它将调用touchesbeent方法,但未找到该单词。这样它就不会触发委托方法 链接第三方自定义标签 代码 我在一个指定的HighlightLabel库中遇到了一些问题,所以我不得不移动到库中。这是一个很好的库,但我在STTweetLabel中发现,当文字中使用表情符号时,它会减少标签上的一些文字,以便我使用

我使用了一个指定的HighlightLabel来显示hashTag和@title name clickable,但是一个指定的HighlightLabel可以在uitable视图中正常工作。它将调用touchesbeent方法,但未找到该单词。这样它就不会触发委托方法

链接第三方自定义标签

代码


我在一个指定的HighlightLabel库中遇到了一些问题,所以我不得不移动到库中。这是一个很好的库,但我在STTweetLabel中发现,当文字中使用表情符号时,它会减少标签上的一些文字,以便我使用下面的代码

进口


是否有任何代码被调用?您说它通过了touchsbegind:withEvent:,但它是否通过了if测试?值是什么?hi@Larme它将检查条件是否与数组touchableLocation中存储的坐标不匹配。当用户当时触摸哈希标记时,触摸方法调用,我将得到该点CGPoint touchLocation=x=145,y=39,并在数组列表中显示该值,打印自我描述->touchableLocation:NSRect:{{413,1.845000028610229529}{{413,1.845万0.413,1.845万0.2828861022955},{{413,1.413,1.843,1.845万0 0.28288602861022955},{8,17},17},学校学校学校教学:{{{{421,1.841.841.845万0.845万0 0.288628282886102282828525252525},},{{{,{{{{{{{{{{{{{{{{{{{{421,1,1,1,1.421,1,1,1,1.841.841.845万0.840.845万0.840.840.840.840.840.28868628282828282828282828282828282828{{459,1.8450000286102295},{8,17}事实上,我用UITableView尝试了同一个库。我收到了所有事件。你能告诉我你的UILabel的层次结构是什么吗?比如UITableView->UITableViewCell->UILabel。这是我用来测试senario的层次结构,它工作得很好。您好@Jay Mehta,我用了相同的层次结构,它工作得很好。有一件事我很满意建议您将NSRect存储在阵列中的初始位置与点击同一链接时接收到的位置之间存在差异。因此,我认为这种差异是由于其层次结构造成的。如果我能为您提供帮助,请告诉我。
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint touchLocation = [touch locationInView:self];
    int count = [touchableLocations count];
    for (int i=0; i < count; i++)
    {

        if (CGRectContainsPoint([[touchableLocations objectAtIndex:i] CGRectValue], touchLocation))
        {
            NSMutableAttributedString *newAttrString = [self.attributedText mutableCopy];
            [newAttrString removeAttribute:NSForegroundColorAttributeName range:[[touchableWordsRange objectAtIndex:i] rangeValue]];
            NSString *string = [touchableWords objectAtIndex:i];
            if([string hasPrefix:@"@"])
                [newAttrString addAttribute:NSForegroundColorAttributeName value:self.selectedMentionTextColor range:[[touchableWordsRange objectAtIndex:i] rangeValue]];
            else if ([string hasPrefix:@"#"])
                [newAttrString addAttribute:NSForegroundColorAttributeName value:selectedHashtagTextColor range:[[touchableWordsRange objectAtIndex:i] rangeValue]];
            else if ([string hasPrefix:@"http://"])
                [newAttrString addAttribute:NSForegroundColorAttributeName value:selectedLinkTextColor range:[[touchableWordsRange objectAtIndex:i] rangeValue]];
            else if ([string hasPrefix:@"https://"])
                [newAttrString addAttribute:NSForegroundColorAttributeName value:selectedLinkTextColor range:[[touchableWordsRange objectAtIndex:i] rangeValue]];
            else if ([string hasPrefix:@"www."])
                [newAttrString addAttribute:NSForegroundColorAttributeName value:selectedLinkTextColor range:[[touchableWordsRange objectAtIndex:i] rangeValue]];
            self.attributedText = newAttrString;

            currentSelectedRange = [[touchableWordsRange objectAtIndex:i] rangeValue];
            currentSelectedString = [touchableWords objectAtIndex:i];
        }
    }
}
   - (CGFloat)heightStringWithEmojis:(NSString*)str fontType:(UIFont *)uiFont ForWidth:(CGFloat)width {

            // Get text
            CFMutableAttributedStringRef attrString = CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);
            CFAttributedStringReplaceString (attrString, CFRangeMake(0, 0), (CFStringRef) str );
            CFIndex stringLength = CFStringGetLength((CFStringRef) attrString);

            // Change font
            CTFontRef ctFont = CTFontCreateWithName((__bridge CFStringRef) uiFont.fontName, uiFont.pointSize, NULL);
            CFAttributedStringSetAttribute(attrString, CFRangeMake(0, stringLength), kCTFontAttributeName, ctFont);

            // Calc the size
            CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(attrString);
            CFRange fitRange;
            CGSize frameSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, 0), NULL, CGSizeMake(width, CGFLOAT_MAX), &fitRange);

            CFRelease(ctFont);
            CFRelease(framesetter);
            CFRelease(attrString);

            return frameSize.height + 5;

        }