2

I am displaying html mails in my app. But it does not stretch images to full size while apple's mail app does. see screenshots below. How apple is Any idea how to achieve this?

  1. My Application web view

enter image description here

Apple's mail app

enter image description here

Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256
  • Can you post a link to a sample web page? Can you post how you embed that html content in the webview? – alex Apr 09 '14 at 18:36

3 Answers3

1

You might try playing with the viewport metatag in the HTML. Even if you can't modify the HTML before it's loaded, you can add / adjust this tag after the fact.

I answered a question about how to accomplish this here:

UIWebView -- load external website, programmatically set initial zoom scale, and allow user to zoom afterwards

Community
  • 1
  • 1
TomSwift
  • 39,369
  • 12
  • 121
  • 149
1

I know this doesn't answer your question, but Apple explicitly warns against embedding UIWebViews in UIScrollViews in the UIWebView Class Reference

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.

But for what it's worth, have you tried the scalesPageToFit property of UIWebView?

solydest
  • 373
  • 1
  • 3
  • 7
0

Not sure where I have this but it was in my notes.
You need to do a bit of JS work in order it to fit once it has been rendered.

#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.... 

    */

}
Sam
  • 350
  • 5
  • 18