Reputation: 874
When developing using the Objective-C language I was able to use one of these solutions (Both not available for Monotouch):
When researching for some information I could find Miguel's implementation in the TweetStation application:
But at that time, he wrote a small parser for detecting links. As I didn't find any kind of special UILabel implementation for Monotouch, I would like to know from you:
What would be the best way I should follow to present clickable links inside a UITableViewCell's UILabel text using Monotouch?
Upvotes: 2
Views: 2207
Reputation: 1272
I've open sourced my TTTAttributedLabel bindings for MonoTouch that you can use to get links in your labels.
Example:
TTTAttributedLabel label = new TTTAttributedLabel ();
label.Text = new NSString ("I love Tink");
label.AddLinkToURL (new NSUrl ("http://tinkapp.com/"), new NSRange (7, 4));
label.Delegate = new LabelDelegate ();
...
class LabelDelegate : TTTAttributedLabelDelegate {
public override void DidSelectLinkWithURL (TTTAttributedLabel label, NSUrl url)
{
Console.WriteLine ("Clicked URL: {0}", url.ToString ());
}
}
Upvotes: 2
Reputation: 2572
In my project I already implemented such control, but due to NDA it's impossible to publish it as open source.
Make your own MonoTouch-native subclass of UILabel
and community will regard you for your work.
Sources of TTTAttributedLabel
and classes NSMutableAttributedString
, CTStringAttributes
, CTParagraphStyleSettings
will help you.
Upvotes: 1