In development, we are most commonly used to load HTML UIWebView, in fact, Uitextview can also load HTML code.
-(void) Viewdidload {
[Super Viewdidload];
Uitextview *textview = [[Uitextview alloc] Initwithframe:cgrectmake (0, Kscreenwidth, kScreenHeight-50)];
[Self.view Addsubview:textview];
HTML code
NSString *htmlstr = @ "
Hiuehuirhfiefguihuiefuwifhewufcehsifhoifhiofhwohfwiohfwoicehicehiheifjkhuhuihwefhuiwhfibfiwehfurwhfuiwhfuiwefhuirwhfiw
Hviurhrihvuerhviohvoiwehvewiohiowhviowvhoiheiohihuihguguygigdusichvregtgtgegtgvrtvtrbtrbtrbtrbtrbtbtvrgeggergrbrt
Hiuehuirhfiefguihuiefuwifhewufcehsicehicehiheifjkhuhuihwefhuiwhfibfiwehfurwhfuiwhfuiwefhuirwhfiw
";
Handle the size of the picture to fit the screen width
NSString *newstring = [htmlstr stringbyreplacingoccurrencesofstring:@ "
nsattributedstring *attributedstring = [[Nsattributedstring alloc] initwithdata:[newstring dataUsingEncoding: Nsunicodestringencoding] options:@{Nsdocumenttypedocumentattribute:nshtmltextdocumenttype} documentAttributes: Nil Error:nil];
Textview.attributedtext = attributedstring;
}
Note: Configure in Info.plist:
<key>app Transport Security Settings</key>
<dict>
<key>allow arbitrary loads</key>
<true/>
</dict>
Note:
//Current screen width
#define kscreenwidth [UIScreen mainscreen].bounds.size.width
//Current screen height
# Define kscreenheight [UIScreen mainscreen].bounds.size.height