我在 UIView 中显示 HTML 内容时遇到问题。以下是我来自服务的 HTML 响应
EmpTable = "<table width='600' border='0' cellspacing='1' cellpadding='8' bgcolor='#d4d4d4'><tr><th>Employee</th><th>Designation</th><th>Date</th><th>Time</th></tr><tr><td>Work Place</td><td>Emp Join Date</td><td>10-09-2009</td><td>17:06</td></tr><tr><td>Emp Attendance</td><td>Emp Id</td><td>11-09-2017</td><td>17:05</td></tr><tr><td>Employee</td><td>Employee Name</td><td>11-09-2017</td><td>09:04</td></tr><tr><td colspan='4' align='RIGHT'><span style='font-family: Verdana; font-size: xx-small;'><strong><span style='color: red;'>*</span>\U00a0- 24 Hrs Format<br /><br /></strong></span></td></tr></table>";
不知道如何在 UIView 中显示相同的 HTML 响应。请找到一些帮助来解决这个问题。TIA
您可以使用 Webview,也可以尝试 UITextView。
NSAttributedString * str = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
textview.attributedText = str;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句