UIWebView放大加载?

时间:2010-10-20 16:30:13

标签: iphone uiwebview

我通过字符串将内容加载到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;
}

这一切都运行正常,正确加载数据,但是,如果我想放大和缩小并将“缩放 - 缩放页面适合”放在其上缩放我的文本,让我双击以取回它全屏。

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

试试这个

wvContent.scalesPageToFit = YES;