Skip to content

Adding multiple detection like email, userhandler and url doesn't work #49

@Chirag89-JackSparrow

Description

@Chirag89-JackSparrow

I add email detection, url detection and userhandler detection on same label but its not working properly.
When i add chirag@y.com its take @y as a userhandler detection part and chirag & .com as a url detection part. So it's not detect chirag@y.com as email part.

NSString *emailRegexString = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSError *error;
    NSRegularExpression *regex = [[NSRegularExpression alloc]initWithPattern:emailRegexString
                                                                     options:0
                                                                       error:&error];
    PatternDescriptor *descriptor = [[PatternDescriptor alloc]initWithRegex:regex withSearchType:PatternSearchTypeAll
                                                      withPatternAttributes:@{NSForegroundColorAttributeName:[UIColor greenColor]}];
    [self.postDetailsL enablePatternDetection:descriptor];

PatternTapResponder userHandleTapAction = ^(NSString *tappedString){
        if ([self.delegate respondsToSelector:@selector(feedCell:didTapOnUserHandle:)]) {
            [self.delegate feedCell:self didTapOnUserHandle:tappedString];
        }
    };
    [self.postDetailsL enableUserHandleDetectionWithAttributes:@{NSForegroundColorAttributeName:[UIColor blueColor], RLTapResponderAttributeName:userHandleTapAction}];

PatternTapResponder URLTapAction = ^(NSString *tappedString){
        if ([self.delegate respondsToSelector:@selector(feedNoMediaCell:didTapOnURLHandle:)]) {
            [self.delegate feedNoMediaCell:self didTapOnURLHandle:tappedString];
        }
    };
    [self.postDetailsL enableURLDetectionWithAttributes:@{NSForegroundColorAttributeName:[UIColor TARedesDisplayColor], NSUnderlineStyleAttributeName:[NSNumber numberWithInt:1], RLTapResponderAttributeName:URLTapAction}];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions