2012-02-28 90 views
2

我在我的应用程序中显示html邮件。但它并没有将图像拉伸到全尺寸,而苹果的邮件应用程序则完成了。见下面的截图。如何苹果是什么想法如何实现这一目标?UIScrollView中的UIWebView不能正确显示内容?

  1. 我的应用程序的Web视图

enter image description here

苹果的邮件应用

enter image description here

+0

你可以发布一个链接到示例网页吗?你能发布你如何在webview中嵌入html内容吗? – alex 2014-04-09 18:36:11

回答

1

我知道这并不能回答你的问题,但苹果明确地警告不要嵌入UIWebViews中在UIWebView类参考中的UIScrollViews中

Important You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled. 

但是对于它的价值,您是否尝试过UIWebView的scalesPageToFit属性?

+0

我没有在scrollView中嵌入UIWebView。是的,我正在使用scalePagesToFit = TRUE; – 2012-03-01 04:10:42

0

不知道我哪里有这个,但它是在我的笔记。
你需要做一点JS工作,以便它适合一旦它被渲染。

#pragma mark - 
#pragma mark UIWebViewDelegate methods 
-(void)webViewDidFinishLoad:(UIWebView *)webView{ 
if (webView!=bioWebView)return; 

float h; 

NSLog(@"web view is %f high", bioWebView.frame.size.height); 
NSString *heightString = [bioWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById("body").offsetHeight;"]; 
NSLog(@"web content is %@ high",heightString); 

h = [heightString floatValue] +12.0f; // convert from string to float plus some extra points because calculation is sometimes one line short 

bioWebView.frame = CGRectMake(bioWebView.frame.origin.x, bioWebView.frame.origin.y, bioWebView.frame.size.width, h); 

// get bottom of text field 
h = bioWebView.frame.origin.y + h + 70; // extra 70 pixels for UIButton at bottom and padding. 
[scrollView setContentSize:CGSizeMake(320, h)]; 

/* 

    position button code here.... 

    */ 

}