简体   繁体   English

UIWebView加载时缩放?

[英]UIWebView zoom on load?

I am loading content into a UIWebView via a string : 我正在通过字符串将内容加载到UIWebView中:

    - (void)viewDidLoad {
    [super viewDidLoad];

    NSString *html = [[[NSString alloc] initWithFormat:(@"<html><head><style type=\"text/css\">body { text-overflow: ellipsis; font-size: 14px;width: 300px;font-family: Helvetica, Verdana, Arial;}table {text-overflow: hidden; word-wrap: break-word font-size: 14px;width: 300px;}tr {padding: 5px;}h1 {font-size: 16px;}h2 {font-size: 14px;color: #aa1121;}h3 {font-size: 14px;}th {color: #aa1121;}li {text-overflow: ellipsis;}</style></head><body><h1>%@</h1><p>%@ - %@</p>%@</body></html>"), selectedTitle, selectedpubDate, selectedmodDate, selectedContent] autorelease]; 

    NSString *jsCommand = [NSString stringWithFormat:@"document.body.style.zoom = 10.5;"];
    [wvContent stringByEvaluatingJavaScriptFromString:jsCommand];
    [wvContent loadHTMLString:html baseURL:nil]; 

    self.navigationItem.title = selectedTitle;
}

This all works fine, loading the data in correctly, however, if i want to zoom in and out and turn the 'Scaling - Scale pages to fit' on it zoom my text out, making me double click to get it back to full screen. 所有这些都可以正常工作,可以正确加载数据,但是,如果我想放大和缩小并在其上打开“缩放-缩放页面以适合它”,则可以缩小文本,使我双击以使其回到全屏。

How do I get around this? 我该如何解决?

尝试这个

wvContent.scalesPageToFit = YES;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM