簡體   English   中英

UIWebView加載時縮放?

[英]UIWebView zoom on load?

我正在通過字符串將內容加載到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;
}

所有這些都可以正常工作,可以正確加載數據,但是,如果我想放大和縮小並在其上打開“縮放-縮放頁面以適合它”,則可以縮小文本,使我雙擊以使其回到全屏。

我該如何解決?

嘗試這個

wvContent.scalesPageToFit = YES;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM