html not proberly scaled for ios device -
i'm trying embed html page webview in ios app. whatever can't seem make scale properly. can see on current app text , image exceed width of screen, not wanted result. how come not scale properly, when i've set widths 100% , set scaletofitpage true?
viewdidload
webview.scrollview.delegate = self webview.scrollview.showshorizontalscrollindicator = false webview.scalespagetofit = true
html code
<!-- template.html --> <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <style type="text/css"> body{ font-family: 'pt sans'; margin-left:0; margin-right:0; margin-top: 0; width: 100%; } .text_div{ padding-left:10px; padding-right:100px; font-size:26px; width: 100%; word-wrap: break-word; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } .text_div p { display: block; width: 100%; word-wrap: break-word; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } .title{ font-size: 40px; padding-left:5px; word-wrap: break-word; padding-right: 10px; margin-top: 10px; width: 100%; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } .main_image { width: 100%; height: 300px; background-size: cover; background-position: center; } .main_image img{ width: auto; height: auto; } </style> </head> <body> <div class="main_image" style="background-image:url([[[main_image]]])" title="[[[alt_desc]]]"></div> <p class="title">[[[title]]]</p> <div class="text_div"> <p>[[[full_text]]]</p> </div> </body> </html>
uiwebview *webview = [[uiwebview alloc] initwithframe:self.view.frame];
nsurl *targeturl = [nsurl fileurlwithpath:html_file_url];
nsurlrequest *request = [nsurlrequest requestwithurl:targeturl];
webview.scalespagetofit=yes;
webview.scrollview.maximumzoomscale=10.0;
webview.scrollview.minimumzoomscale=1.0;
webview.backgroundcolor=[uicolor whitecolor];
[self.view addsubview:webview];
[webview loadrequest:request];
Comments
Post a Comment