2012-06-26 13 views
0

我已經實現了一個UIWebView並顯示來自Web服務來的內容,這是低於如何適應所有的內容從Web服務進來的UIWebView

webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,320,460)]; 
webView.scalesPageToFit = YES; 
webView.dataDetectorTypes = YES; 
webView.autoresizingMask = UIViewAutoresizingFlexibleHeight; 
webView.delegate = self; 

NSURL *targetURL = [NSURL URLWithString:delegate.S_Title]; 
request = [NSURLRequest requestWithURL:targetURL]; 
[webView loadRequest:request]; 
[self.view addSubview:webView]; 

代碼然而,當我向下滾動到下,它沒不滾動顯示webview顯示的完整內容。

回答

0

試試這個,在您加載了UIWebView中的內容後,您可以使用它的stringByEvaluatingJavaScriptFromString:方法來詢問html文檔的高度。這有點棘手,但應該工作。

你可以做這樣的事情:

NSInteger height = [[webView stringByEvaluatingJavaScriptFromString: 
    @"document.body.scrollHeight"] integerValue]; 

的scrollHeight屬性mught不是最好的。你有幾個選擇。試驗提及的文件屬性here

相關問題