iphone - Slow loading UIWebView from string -
i trying load uiwebview string follows:
nsstring* plaincontent = @"..."; nsstring* htmlcontentstring = [[nsstring stringwithformat: @"<html>" "<style type=\"text/css\">" "body { background-color:transparent; font-family:arial-boldmt; font-size:18;}" "</style>" "<body>" "<p>%@</p>" "</body></html>", plaincontent] retain]; [webview loadhtmlstring:htmlcontentstring baseurl:nil]; where plain content has simple html 5 links , 400 characters. i'm trying run on iphone5, , first time loads take few seconds. know why happening , how fix this?
this happens because of css used in rendering web page. default behavior when loading page locally. can consider in first load, uiwebview doesn't have cache , create cache page.
to make little fast try loading page file e.g.
nsurl *url = [nsurl fileurlwithpath:[[nsbundle mainbundle] pathforresource:@"filepath" oftype:@"html" indirectory:@"."]]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; [webview loadrequest:request]; css body { background-color:transparent; font-family:arial-boldmt; font-size:18;} increase time of loading page.
Comments
Post a Comment