In Xmarin, we basically used c# language to develop an iOS application, we need to use hyperlink in textview.
But if we wanna change to Obj-c code, that's the same grammar.
Created
October 12, 2016 00:57
-
-
Save pokk/286259debcb1e91bb757df94fa9040be to your computer and use it in GitHub Desktop.
Using a heyperlink at TextView in iOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var attributedString = new NSMutableAttributedString("Want to learn iOS? You should visit the best source of free iOS tutorials!"); | |
attributedString.AddAttribute(UIStringAttributeKey.Link, new NSString("http://www.google.com.tw"), new NSRange(19, 55)); | |
this.textContent.AttributedText = attributedString; | |
this.textContent.ShouldInteractWithUrl = ShouldInteractWithUrl; | |
bool ShouldInteractWithUrl (UITextView textView, NSUrl url, NSRange characterRange) | |
{ | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment