iOS中的label加载HTML文件
来源:互联网 发布:linux 图形安装 kvm 编辑:程序博客网 时间:2024/05/01 02:38
NSString * htmlString =@"<a class='blue' href='http://10.5.225.14:8080/UserCenter/toUserIndex/ecfbdc8c98be410a9ad238511dc16e06.html' target='_blank'>@王琦琦 </a>jksjkdfsdfjsd<a class='blue' href='http://10.5.225.14:8080/UserCenter/toUserIndex/bb4294141cd141b0ba69d788811b7b7d.html' target='_blank'>@leef </a>jfsdlkfjsd<a class='blue' href='http://10.5.225.14:8080/UserCenter/toUserIndex/40c4973fe3fc4d178ffb123e2f765c79.html' target='_blank'>@lee </a>[色]";
NSMutableAttributedString * attrStr = [[NSMutableAttributedStringalloc] initWithData:[htmlStringdataUsingEncoding:NSUnicodeStringEncoding]options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType }documentAttributes:nilerror:nil];
NSLog(@"获取的文本是:%@",attrStr);
NSError *error;
NSString *regulaStr =@"\\bhttps?://[a-zA-Z0-9\\-.]+(?::(\\d+))?(?:(?:/[a-zA-Z0-9\\-._?,'+\\&%$=~*!():@\\\\]*)+)?";
NSRegularExpression *regex = [NSRegularExpressionregularExpressionWithPattern:regulaStr
options:NSRegularExpressionCaseInsensitive
error:&error];
NSArray *arrayOfAllMatches = [regexmatchesInString:attrStr.stringoptions:0range:NSMakeRange(0, [htmlStringlength])];
NSLog(@"%@",arrayOfAllMatches);
for (NSTextCheckingResult *matchin arrayOfAllMatches)
{
NSString* substringForMatch = [htmlStringsubstringWithRange:match.range];
NSLog(@"%@",substringForMatch);
}
UILabel * myLabel = [[UILabelalloc] initWithFrame:self.view.bounds];
myLabel.attributedText = attrStr;
[self.viewaddSubview:myLabel];
- iOS中的label加载HTML文件
- iOS label加载html富文本内容
- ios 加载资源中的Html
- html中的label标签
- html 中的 label
- HTML中的<label>标签
- Html中的label标签
- UITextView,Label加载html代码
- UITextView,Label加载html代码
- iOS label内容加载不全
- iOS之加载HTML中的特殊字符
- html中的label宽度调整
- ios 加载本地的Html文件
- ios UIWebView 加载网页、文件、 html
- ios UIWebView 加载网页、文件、 html
- ios UIWebView 加载网页、文件、 html
- ios UIWebView 加载网页、文件、 html
- ios UIWebView 加载网页、文件、 html
- Devu, the Dumb Guy
- 多线程问题
- 单例模式
- Caffe傻瓜系列(3):激活层(Activiation Layers)及参数
- iOS如何将App程序发布到App Store?
- iOS中的label加载HTML文件
- linux网络编程
- [Android实例] 仿Win8磁铁效果,能够拖动改变Merto位置
- 使用Redis的Java客户端Jedis
- Keymob发力程序化交易 拥抱移动广告未来
- Java编程思想读书笔记(一)
- 畅想“互联网 + ”,畅想未来
- Python文件夹与文件的操作
- 利用系统自带App导航