[英]UIWebView content width to custom size
我在UIWebView
顯示Disqus
網頁。 該頁面具有移動版本,可調整其對設備的視圖大小。 我的問題是UIWebView
將其內容設置為設備寬度,而我的webView大約是設備寬度的一半。 因此,我可以將我的webview向右和向左滾動。 我已經嘗試過這樣的事情: SOF問題 ,設置contentSize
等但沒有結果。
您可以嘗試入侵webview css並嘗試將其寬度更改為您的屏幕寬度/ 2。
我已經完成了以下代碼片段,它完全有效:
[aWebView loadRequest:aRequest progress:nil success:^NSString *(NSHTTPURLResponse *response, NSString *HTML) {
NSMutableString *mutableString = [[NSMutableString alloc] initWithString:HTML];
NSRange range = [mutableString rangeOfString:@"width=device-width"]; // or whatever you have in response
[mutableString replaceCharactersInRange:range withString:[NSString stringWithFormat:@"width=%d", (int)CGRectGetWidth(aWebView.frame)]];
return mutableString;
} failure:nil];
感謝我的同事的想法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.