xcode 如何在 UITextView 中创建可点击的链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6653975/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make a clickable link in UITextView
提问by mrbaker
I am developing an iphone app right now where i will be displaying an overview text with entries that can be found later in the app. I am wondering if there is a way to make a specific work clickable to send me to another screen that will display more information about the place that was clicked.
我现在正在开发一个 iphone 应用程序,我将在其中显示一个概述文本,其中包含稍后可以在应用程序中找到的条目。我想知道是否有一种方法可以使特定作品可点击,以便将我发送到另一个屏幕,该屏幕将显示有关被点击地点的更多信息。
回答by Aravindhan
You can use this...
你可以用这个...
self.myTextView.dataDetectorTypes =UIDataDetectorTypeLink;
回答by Marek Manduch
if you want active substring in your UITextView then you can use my extended TextView... its short and simple. You can edit it as you want.
如果你想在你的 UITextView 中激活子字符串,那么你可以使用我的扩展 TextView ......它简短而简单。您可以根据需要对其进行编辑。
how to use (range = substring location):
如何使用(范围=子串位置):
[self.textView addTapActionWithRange:range withActionBlock:^{
// anything you want to do - show something
}];
source code: https://github.com/marekmand/ActiveSubstringTextView


