ios 标签 html,ios 显示HTML标签文本
第一種:
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *strHTML = @"
你好
這是一個例子,請顯示
外加一個tableaaaabbbbcccc
";
UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.frame];
[self.view addSubview:webView];
[webView loadHTMLString:strHTML baseURL:nil];
}
第二種:
NSString * htmlString = @" Some html string \n This is some text! ";
NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
UILabel * myLabel = [[UILabel alloc] initWithFrame:self.view.bounds];
myLabel.attributedText = attrStr;
[self.view addSubview:myLabel];
//正則去除網絡標簽
-(NSString *)getZZwithString:(NSString *)string{
NSRegularExpression *regularExpretion=[NSRegularExpression regularExpressionWithPattern:@"]*>|\n"
options:0
error:nil];
string=[regularExpretion stringByReplacingMatchesInString:string options:NSMatchingReportProgress range:NSMakeRange(0, string.length) withTemplate:@""];
return string;
}
總結
以上是生活随笔為你收集整理的ios 标签 html,ios 显示HTML标签文本的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html怎么做模糊条纹,如何使用纯CSS
- 下一篇: Mac OS X 安装和配置ngrok