0

I am trying to open url using TTStyledTextLabel. I searched but found that I have to append <a href=''></a> this in my string.

Tried but it still not working.

    TTStyledTextLabel *tnc = ....;
    NSString *message = @"My message";

    message = [NSString stringWithFormat:@"<a href=''></a> %@ http://www.google.co.in", message];
    TTStyledText *text = [TTStyledText textFromXHTML:message lineBreaks:YES URLs:YES];

    tnc.text = text;

Am I doing this in correct way. Whenever I tap on url it gets highligted but makes my other string invisible. Should I have to use a webView to open a url or it will directly open a safari?

JiteshW
  • 2,195
  • 4
  • 32
  • 61

1 Answers1

0

You message string is not correct.May be it's the following:

message = [NSString stringWithFormat:@"<a href='http://www.google.co.in'>%@</a>", message];

When you tap the message,it will open a url in a webView.

jasonhao
  • 2,098
  • 1
  • 14
  • 7