APLUrlTextView 0.0.3

APLUrlTextView 0.0.3

测试测试
语言语言 Obj-CObjective C
许可 MIT
发布最后发布2015年9月

Tino RachuicgMathias KöhnkeMichael KamphausenMathiasKoehnkeNico SchümannHeiko WichmannStephan LernerFamara Kassama维护。



  • Tino Rachui

这是一个简单的UITextView扩展,允许添加URL并在用户选择这些URL时通知。您可以使用UITextView的'linkTextAttributes'来定义嵌入链接的样式。

安装

通过在Podfile中添加以下内容进行安装

pod 'APLUrlTextView', '0.0.2'

使用

导入头文件

#import "APLUrlTextView.h"
#import "APLHrefString.h"

如此使用APLUrlTextView

...
self.textView.delegate = self;
...
NSURL *targetURL = [NSURL URLWithString:"..."];
NSRange linkRange = NSMakeRange(...);
[self.textView addLinkToURL:targetURL withRange:linkRange];
...

// Implement the delegate method extending the UITextViewDelegate method
// in order to be informed about URLs being touched by the user
-(void)textView:(APLUrlTextView *)label didSelectLinkWithURL:(NSURL *)url {
  ...
}

Use APLHrefString to parse strings containing 'hrefs' like this "A string with 
<href="http://www.apploft.de">a link</href>" and get a corresponding attributed string plus rnages and urls to be used for the APLUrlTextView.