Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8976483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:09:01+00:00 2026-06-15T19:09:01+00:00

I am using OHAttributeLabel to add custom links to my label’s text. The code

  • 0

I am using OHAttributeLabel to add custom links to my label’s text. The code that I am using is pasted below. It used to work with the older version of OHAttributed label (2010), however with the new version (recently updated), the text in my label are no longer clickable as links.

Can anyone advise what I am missing here?

// Set Question Label
Question *question = self._answerForCell.question;
NSString *questionText = [NSString stringWithFormat:@"Q: %@", question.text];
CustomOHAttributLabel *thisQuestionLabel = (CustomOHAttributLabel *)[self.contentView viewWithTag:QUESTIONLABEL_TAG];

//Set up dictionary for question
NSString *questionStr = [question.text stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];

NSString *urlForQn = [NSString stringWithFormat:@"dailythingsfm://redirect_to/questions/%@/answers?text=%@&nickname=%@&question_id=%@&question_curious=%i&showEveryOneTab=%i", question.slug, questionStr, [[UserInfo sharedUserInfo] getNickname], question.qid, question.curious, 1];
NSString *qnStartIndex = @"0";
NSString *qnLength = [NSString stringWithFormat:@"%i", [questionText length]];

NSDictionary *qnDict = [NSDictionary dictionaryWithObjectsAndKeys:qnStartIndex, @"start", qnLength, @"length", urlForQn, @"url", nil];
NSArray *array = [NSArray arrayWithObject:qnDict];
[thisQuestionLabel setLabelwithText:questionText fontSize:QUESTION_FONT_SIZE andSubStringToURLArrayViaRange:array withHexColor:@"#555555"];


//Method to set the text in UILabel to a custom link
- (void)setLabelwithText:(NSString *)text fontSize:(CGFloat)fontSize andSubStringToURLArrayViaRange:(NSArray *)array withHexColor:(NSString *)textColor
{
    NSMutableAttributedString *attrStr = [NSMutableAttributedString attributedStringWithString:text];
    [attrStr setFont:[UIFont systemFontOfSize:fontSize]];
    [attrStr setTextColor:[UIColor grayColor]];
    [self removeAllCustomLinks];

    for (NSDictionary *dict in array) {
        NSString *start = [dict objectForKey:@"start"];
        NSString *length = [dict objectForKey:@"length"];
        NSString *url = [dict objectForKey:@"url"];

        NSUInteger startIndex = [start intValue];
        NSUInteger len = [length intValue];

        NSRange range = NSMakeRange(startIndex, len);

        [attrStr setFont:[UIFont boldSystemFontOfSize:fontSize] range:range];
        [attrStr setTextColor:[UIColor colorWithHexString:textColor] range:range];
        [self addCustomLink:[NSURL URLWithString:url] inRange:range];
    }

    self.attributedText = attrStr;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:09:03+00:00Added an answer on June 15, 2026 at 7:09 pm

    I have to use ‘setLink’ method instead of addCustomLink for the latest OHAttribute Library (3.2.1)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
using a binary search tree I need to add to a vector all int
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using C#, I need a class called User that has a username, password, active
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
I am successfully adding links to a UILabel via OHAttributeLabel and -(void)addCustomLink:(NSURL*)linkUrl inRange:(NSRange)range; In
I have heard that I can display a NSAttributedString using CoreText, can anyone say
I am using OHAttributeLabel in my iPhone Application but now I am getting an
Using SSRS 2008 R2 I have a background process that dynamically generates RDL for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.